Using A Macro To Name A 2-dimensional Range

  • Thread starter Thread starter Chuckles123
  • Start date Start date
C

Chuckles123

This is so easy in a spreadsheet. I want the macro to name
two-dimensional range: the left-most column and the right-most colum
are fixed; the bottom row is the last row of the spreadsheet (but, thi
is a variable); the top row is a fixed number of rows above the botto
row; and, there are some empty cells in the range.

How much harder can it be in a macro???

Thanks for a response.
Chuckles12
 
Maybe something like this will help:

Const LeftCol = 3
Const RightCol = 10
Const NumRows = 30

Dim BottomRow As Long

BottomRow = Cells(Rows.Count, LeftCol).End(xlUp).Row
TopRow = BottomRow - NumRows + 1
Range(Cells(TopRow, LeftCol), Cells(BottomRow, RightCol)).Name = "SomeName"
 

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

Back
Top