Iterate Range

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,099
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Just wondering if there's a preferred way to extract the High and low row numbers. My range address is $C$54:$C$400.
Do I use a For-Next Loop ? If yes, is 54 and 400 available from the range ? I could Split on "$" and remove the ':' but doesn't seem very elegant.
I looked at For each item In range ( cell1, cell2) but that would need still need the range values.
There's also a need sometimes to go 400 to 54.
 
For iteration ascending.
VBA Code:
Sub Iterate1()
Dim adr
Dim cel As Range
For Each cel In Range("$C$54:$C$400")
adr = cel.Address
Next cel
End Sub
For iteration descending.
VBA Code:
Sub Iterate2()
Dim adr,  T&
Dim cel As Range
For T = 0 To  Range("$C$54:$C$400").Rows.Count
adr = Range(Split("$C$54:$C$400", ":")(1)).Offset(-T, 0).Address
'adr = cel.Address
Next T
End Sub
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top