calling cells in for-loops
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 |
calling cells in for-loops
For lngRow = 1 to 5
Msgbox Cells(lngRow,1) Msgbox Range("A" & lngRow) Next If this post helps click Yes --------------- Jacob Skaria "Derrick" wrote: 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 |
calling cells in for-loops
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 "Derrick" wrote: 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 |
calling cells in for-loops
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. -- Rick (MVP - Excel) "Derrick" wrote in message ... 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 |
All times are GMT +1. The time now is 06:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com