Simple VBA question

C

CWatters

I have a named range of cells that I wish to process with a For-Next
loop. Lets say the range A1:A96532 is named TempX

I can obviously write

Def i Long
For i = 1 to 96532
' do something
Next

but there must be a better way that involves getting the length of the
named range automatically. Does something like this work..

Def i Long
For i = 1 to count("TempX")
' do something
Next

Thanks
 
C

Claus Busch

Hi,

Am Wed, 06 Feb 2013 08:38:51 +0000 schrieb CWatters:
I have a named range of cells that I wish to process with a For-Next
loop. Lets say the range A1:A96532 is named TempX

try:
Dim rngC As Range
For Each rngC In Range("TempX")
'do something
Next


Regards
Claus Busch
 
C

CWatters

Hi,

Am Wed, 06 Feb 2013 08:38:51 +0000 schrieb CWatters:


try:
Dim rngC As Range
For Each rngC In Range("TempX")
'do something
Next


Regards
Claus Busch


Hi Claus. Many thanks for that. I'll give it a go.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top