View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default 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?