calling cells in for-loops

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

whats the code that will allow me to select the row that the for loop is
currently on.. eg, if the loop starts at 1 goes to 5, and is currently
working on row 2,
i want to be using cell (column, 2) in my calcs..
thanks
 
For lngRow = 1 to 5
Msgbox Cells(lngRow,1)
Msgbox Range("A" & lngRow)
Next


If this post helps click Yes
 
The answer depends on how your running your loop

It could be

activecell.offset(,n) where n is the offset required from the current column

or maybe

c.offset(,n)

If you post your code it will be easier to answer

Mike
 
First off, the property call you want is Cells (note the 's' at the end) and
you have the arguments reversed (row first, then column). Assuming your use
of column is a stand-in for the actual column number or quoted letter, you
would use your loop counter for the currently being processed row number.
For example, if your loop counter were RowNumber, then your loop would be
set up like this...

For RowNumber = 1 To 5
.....
ValueInColumnBofCell = Cells(RowNumber, "B").Value
.....
Next

Now, of course, there are other considerations as well. For example, if you
are referencing something other than the active worksheet, there would be
references to that in the statement; but, in general, the above should get
you started.
 
Back
Top