title: Why is Excel VBA rounding my integer division results?
body: <p>I'm writing a VBA macro in Excel 2002 to manipulate date from a device that gives 10 values on each of 4 channels.</p>
  
  <p>When I try to divide an integer by another integer to calculate the row and column, the result shows that it's using bankers rounding, as if it was a floating point variable.</p>
  
  <pre><code>Sub TestRounding()
      Dim Y As Integer
      Dim Field As Integer
      Dim Channel As Integer
  
      ActiveWorkbook.Sheets.Add
      ActiveWorkbook.ActiveSheet.Cells.Select
      range("A1").Select
  
      For Field = 1 To 40
          Channel = (Field - 1) / 10
          Y = Field - 1
          ActiveSheet.range("A1").Offset(Y, Channel).Value = Field
      Next Field
  
  End Sub
  </code></pre>
  
  <p>Y is the row to put the output in, which I usually set with</p>
  
  <pre><code>Y = (Field -1) mod 10
  </code></pre>
  
  <p>but I've left it as</p>
  
  <pre><code>Y = Field - 1
  </code></pre>
  
  <p>to illustrate the point more clearly in the resulting worksheet.</p>
  
  <p>Channel is supposed to be the column that the output is put in.</p>
  
  <p>When I run this macro, the values 1-6 get put in column A, then 7-15 get put into Column B, 16-26 get put into Column C, then 27-35 in Column D then 36-40 in Column E.</p>
  
  <p>What I expected was that values 1-10 go into column A, 11-20 into column B, 21-30 into column C and 31-40 into column D.</p>
  
  <p>I'm used to C and C++ where if I divide an integer by another integer, the result is calculated using integer maths. What's different in VBA? </p>