ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using VB to find next cell in range (https://www.excelbanter.com/excel-programming/272388-re-using-vbulletin-find-next-cell-range.html)

Bob Kilmer

Using VB to find next cell in range
 
You can treat the range as a vertical array of Cells and access them by
index:.

With Range("A3:A350")
Debug.Print .Cells(1).Value 'cell A3
Debug.Print .Cells(2).Value 'cell A4
Debug.Print .Cells(3).Value 'cell A5
...
Debug.Print .Cells(.Cells.Count).Value 'cellA350
End With

Range("A3:A350").Cells.Count gives the total number of cells in the range.

You could access the entire series in a counter controlled loop.

Bob Kilmer


"Tim" wrote in message
...
Can someone help me find the code that will allow me to
find the next cell in a range. I have a range set up,
i.e. Range("A3:A350"), and a range variable set to the
first cell A3. As my code executes I need the range
variable originally set to A3 to move down the larger
range of ("A3:A350"), say to A4. I thought the Next
property might work but I am having trouble with it. Any
help would be appreciated!!

Tim McPhillips





All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com