Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro command to move cell selection
I am writing a macro for a spreadsheet where I have values stored in one
column. I want to run a loop where each time the loop runs, I select each cell in the column. For example, my values are stored in column A, cells 1 through 7. On loop 1 I want to select cell A1, loop 2 select cell A2, loop 3 select A3 and so on. How can I set this up in a macro to increment cell selection as I move through my loop? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro command to move cell selection
I'm really not sure whay you can do with this, but is this what you are
wanting? Sub SelectionLoop() Dim i As Long For i = 1 To 7 Cells(i, "A").Select Next i End Sub Hope this helps! If so, please click "YES" below. -- Cheers, Ryan "DOOGIE" wrote: I am writing a macro for a spreadsheet where I have values stored in one column. I want to run a loop where each time the loop runs, I select each cell in the column. For example, my values are stored in column A, cells 1 through 7. On loop 1 I want to select cell A1, loop 2 select cell A2, loop 3 select A3 and so on. How can I set this up in a macro to increment cell selection as I move through my loop? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro command to move cell selection
Sub DoSomething()
Dim X as Long For X = 1 To 7 'or any number that addresses the whole range Range("A" & X).Select .. . . your value manipulation code goes here Next X End Sub HTH "DOOGIE" wrote: I am writing a macro for a spreadsheet where I have values stored in one column. I want to run a loop where each time the loop runs, I select each cell in the column. For example, my values are stored in column A, cells 1 through 7. On loop 1 I want to select cell A1, loop 2 select cell A2, loop 3 select A3 and so on. How can I set this up in a macro to increment cell selection as I move through my loop? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro command to move cell selection
I am sure you are looking for something else and you dont need to really
select the cell to acheive that. Go through the below code to see how to get the cell value from any row during this loop. Sub Macro1() Dim cell As Range For Each cell In Range("A1:A7") 'cell value MsgBox cell.Value 'cell value of same row 1st column to the right MsgBox cell.Offset(, 1).Value, , "ColB value of the same row" 'Refer another column in the same row 2nd col in the same row MsgBox cell.Offset(, 2).Value, , "ColC value of the same row" 'OR MsgBox Range("C" & cell.Row) 'select the cell cell.Select Next End Sub -- Jacob "DOOGIE" wrote: I am writing a macro for a spreadsheet where I have values stored in one column. I want to run a loop where each time the loop runs, I select each cell in the column. For example, my values are stored in column A, cells 1 through 7. On loop 1 I want to select cell A1, loop 2 select cell A2, loop 3 select A3 and so on. How can I set this up in a macro to increment cell selection as I move through my loop? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I move to the first cell in the selection in Excel 07? | Excel Worksheet Functions | |||
How can I move the cell pointer down one row in a macro command? | Excel Programming | |||
How do you move the selection one cell to the right in a macro | Excel Programming | |||
Newbie - Move Selection one cell to right | Excel Programming | |||
Move selection down one cell | Excel Programming |