Setting a range in a named range

A

Askjerry

Let's say I named the first column "ALPHA" and that I want to perfor
some function on it...

If I use this...
Set myRange = Range("A2", Range("A65536").End(xlUp))

It will process only those rows with data in them... so if I typ
information into the first 5 rows... it will process rows 2 through 5
All good.

But if someone inserts a column... the process looks at the wron
field... so I tried...

Set myrange = Range(Range("ALPHA"), Range("ALPHA").End(xlUp))

But it tries to process 1,048,576 rows. !!!!

What I need is the correct way to write something like...

Set myrange = Range(Range("ALPHA".ROW=2 ), Range("ALPHA". ROW
1000000).End(xlUp))

How do I specify a named range-row?

How do I specify the last row in a range that actually has data?

Thanks!
Jerr
 
R

Ron Rosenfeld

Let's say I named the first column "ALPHA" and that I want to perform
some function on it...

If I use this...
Set myRange = Range("A2", Range("A65536").End(xlUp))

It will process only those rows with data in them... so if I type
information into the first 5 rows... it will process rows 2 through 5.
All good.

But if someone inserts a column... the process looks at the wrong
field... so I tried...

Set myrange = Range(Range("ALPHA"), Range("ALPHA").End(xlUp))

Something like:

Dim MyRange As Range
Set MyRange = Range(Range("ALPHA")(RowIndex:=2), _
Cells(Rows.Count, Range("ALPHA").Column).End(xlUp))
 
A

Askjerry

Something like:

Dim MyRange As Range
Set MyRange = Range(Range("ALPHA")(RowIndex:=2), Cells(Rows.Count
Range("ALPHA").Column).End(xlUp))

That worked perfectly! Thank you so very much!

Jerr
 

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