Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
BEGINNER'S QUESTION:
I am creating an application in Excel that will use a block of cells for display - 9 rows and 9 columns - A1-A9, B1-B9, ..., I1-I9. In several places, I would like to look at or write to each cell using a FOR loop in VBA: FOR row=1 to 9 FOR col=1 TO 9 write to cell at (row, col) NEXT col NEXT row How do I create cell references dynamically in a loop based on "row" and "col"? Is there a better way to programatically cycle through a series of cells other than using FOR loops? Thank you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try ActiveWindow.ActiveSheet.Cells(row, col) or just Cells(row,col).
"Negnog" wrote in message ... How do I create cell references dynamically in a loop based on "row" and "col"? Is there a better way to programatically cycle through a series of cells other than using FOR loops? Thank you. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use
Cells(row,col).Value = 123 As an aside, 'row' is a reserved word in Excel/VBA, and good programming practice would preclude it from being used as a variable name. Use 'RowNum' or something similar instead. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Negnog" wrote in message ... BEGINNER'S QUESTION: I am creating an application in Excel that will use a block of cells for display - 9 rows and 9 columns - A1-A9, B1-B9, ..., I1-I9. In several places, I would like to look at or write to each cell using a FOR loop in VBA: FOR row=1 to 9 FOR col=1 TO 9 write to cell at (row, col) NEXT col NEXT row How do I create cell references dynamically in a loop based on "row" and "col"? Is there a better way to programatically cycle through a series of cells other than using FOR loops? Thank you. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cells(Row, col) = value to write to cell
"Negnog" wrote: BEGINNER'S QUESTION: I am creating an application in Excel that will use a block of cells for display - 9 rows and 9 columns - A1-A9, B1-B9, ..., I1-I9. In several places, I would like to look at or write to each cell using a FOR loop in VBA: FOR row=1 to 9 FOR col=1 TO 9 write to cell at (row, col) NEXT col NEXT row How do I create cell references dynamically in a loop based on "row" and "col"? Is there a better way to programatically cycle through a series of cells other than using FOR loops? Thank you. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For loops are good. You might look at For Each of a Range object, example:
Dim c For Each c In ActiveWindow.RangeSelection Next c "Negnog" wrote in message ... "col"? Is there a better way to programatically cycle through a series of cells other than using FOR loops? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
START UP FORMS FOR DOG WALKING BUSINESS (HELP ) | Excel Discussion (Misc queries) | |||
walking menu | Excel Worksheet Functions | |||
Help - loop through cells in a range that are not together (several different cells as Target) | Excel Programming | |||
Loop through cells | Excel Programming | |||
VBA loop cells | Excel Programming |