Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycling through the cells in a range
Can someone tell me how to cycle through the cells in a
range that has more than one cell selected? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycling through the cells in a range
for each cell in Selection
msgbox cell.Address Next -- Regards, Tom Ogilvy "Wandering mage" wrote in message ... Can someone tell me how to cycle through the cells in a range that has more than one cell selected? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycling through the cells in a range
Thank you.
-----Original Message----- for each cell in Selection msgbox cell.Address Next -- Regards, Tom Ogilvy "Wandering mage" wrote in message ... Can someone tell me how to cycle through the cells in a range that has more than one cell selected? . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycling through the cells in a range
Wandering mage wrote:
Can someone tell me how to cycle through the cells in a range that has more than one cell selected? For i = 1 To Selection.Count MsgBox Selection(i).Address Next Alan Beban |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycling through the cells in a range
Just to add a little more explanation for the OP's benefit (not intended as
a criticism of Alan's suggested solution). It could be as simple as the OP actually does not know how to loop through a multicell contiguous range in which Alan's suggestion works well. I saw it as a multicell discontiguous range in which Alan's solution would not work (as written) but using "for each cell in selection" would work (in both cases). to illustrate: Sub Tester9() Debug.Print Selection.Address For i = 1 To Selection.Count Debug.Print i, Selection(i).Address Next End Sub produces: $F$22,$H$22,$F$31,$H$31 1 $F$22 2 $F$23 3 $F$24 4 $F$25 and using For each Sub Tester10() Debug.Print Selection.Address i = 0 For Each cell In Selection i = i + 1 Debug.Print i, cell.Address Next End Sub produces: $F$22,$H$22,$F$31,$H$31 1 $F$22 2 $H$22 3 $F$31 4 $H$31 just some additional information that may prove useful. -- Regards, Tom Ogilvy "Alan Beban" wrote in message ... Wandering mage wrote: Can someone tell me how to cycle through the cells in a range that has more than one cell selected? For i = 1 To Selection.Count MsgBox Selection(i).Address Next Alan Beban |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Tab keeps cycling through the same row | Excel Discussion (Misc queries) | |||
Cycling through workbooks | Excel Discussion (Misc queries) | |||
Cycling though all sheets in the workbook | Excel Programming | |||
Cycling through worksheets | Excel Programming | |||
Need UDF help; cycling through various sheets using VBA name property | Excel Programming |