How do i loop through cells in my named ranges

Sahil123

Well-known Member
Joined
Oct 31, 2011
Messages
673
Hi All,

I have 3 named ranges in my sheet

How do i loop through each cell in those named ranges

For cell in ????
Cell.select
Next Cell

and how can i also set it up as a variable as an alternative i.e

Arr = Range("A","B","C")

For each cell in Arr
Cell.select
Next Cell

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi All,

I have 3 named ranges in my sheet

How do i loop through each cell in those named ranges

For cell in ????
Cell.select
Next Cell

and how can i also set it up as a variable as an alternative i.e

Arr = Range("A","B","C")

For each cell in Arr
Cell.select
Next Cell

Thanks


Bump anyone

Thank You So Much
 
Upvote 0
Assuming you have valid named ranges named A B and C
Although I don't think C is a valid name, it's short for Column..
But I assume A B and C are just simple examples..

This should work
Code:
Set Arr = Range("A, B, C")
 
For Each Cell In Arr
    Cell.Select
Next Cell
 
Upvote 0
Assuming you have valid named ranges named A B and C
Although I don't think C is a valid name, it's short for Column..
But I assume A B and C are just simple examples..

This should work
Code:
Set Arr = Range("A, B, C")
 
For Each Cell In Arr
    Cell.Select
Next Cell

Thank You

Yep they were just used to show as an example

Waht if i named them in my spreadsheet

how would i reference them in my for each loop?

Would i need to define it in a variable or could i omit that and do something like

For each cell in (Named ranges)??
Next cell


Thanks
 
Upvote 0
That's what I just showed.

If you have valid named ranges, say
rng1 = A1:A10
rng2 = E1:E20
rng3 = G10:J30

Then this will loop through ALL of those cells

Code:
Set Arr = Range("rng1, rng2, rng3")
 
For Each Cell In Arr
    Cell.Select
Next Cell
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

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