Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I move to the first cell in the selection in Excel 07? Ruchir[_2_] Excel Worksheet Functions 7 October 31st 09 03:25 AM
How can I move the cell pointer down one row in a macro command? Ken Excel Programming 6 September 3rd 06 03:07 AM
How do you move the selection one cell to the right in a macro fder Excel Programming 3 May 11th 06 06:51 PM
Newbie - Move Selection one cell to right dpolkinhorn Excel Programming 4 September 3rd 04 07:38 PM
Move selection down one cell GB[_3_] Excel Programming 3 October 12th 03 02:47 PM


All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"