Excel VBA - Accessing row and column indices from named ranges?

B

billy600

Hi,

I'm using a named range to mark the right most and bottom most column
and rows of interest. "lastrow" and "lastcolumn" respectively. There i
data outside this area that I wish to keep but the number o
rows/columns inside can grow with the project.

My intention is to select this area with a construct similar to

cells("lastrow","lastcolumn").select

Of course this will not work unless I can derive the column index fro
"lastcolumn" and row index from "lastrow". How is this achieved?

I've just thought I can place a named cell at the intersection of thes
two ranges and use that as a range however I'm sure I'll want to get
row index or column index from a named range so I'll continue with thi
post.

Many thanks in advance for any help.

Billy60
 
D

Dave Peterson

You have a range name for the lastRow and a range name for the lastColumn?

dim LastRow as Range
dim LastColumn As range

with activesheet
set lastrow = .range("lastrow")
set lastcolumn = .range("lastcolumn")
.cells(lastrow.row,lastcolumn.column).select
end with

or...

dim LastRow as Long
dim LastColumn As Long

with activesheet
lastrow = .range("lastrow").row
lastcolumn = .range("lastcolumn").column
.cells(lastrow,lastcolumn).select
end with


might work for you.
 
Top