VBA Created Named Range to "Last Row" Goes 2,000 Rows Past Last Row

Shiseiji

Board Regular
Joined
Oct 23, 2009
Messages
214
Office Version
  1. 2019
Platform
  1. Windows
Hi. I'm working through step-by-step creating a named range macro that will, eventually I hope, result in a range named the same as the worksheet name. My range starts at A2 and "should end" in column J at last row 416. The result I'm getting is =Nov_02_2016!$A$2:$J$2416. Clearing/deleting the rows from 417 - 2416 and rerunning the VB returns the same results. Obviously I'm not doing something correctly . . . .

Sub birrange3()
'm_birrange3
Dim lastRow As Long
lastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Application.Volatile True
Range("A2:J2" & lastRow).Select
ActiveWorkbook.Names.Add Name:="birrange3", RefersTo:=Selection
End Sub

After that it's figure out how to use something like ActiveSheet.Name = Format(Now(), "mm-dd-yy") with a prefix to name the range . . .

As always from the "Not a real coder . . ."
Just the one eyed person in the land of the blind.

THANKS!!!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
A2:J2 is your clue area try dropping the 2 from J2
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,519
Messages
6,125,297
Members
449,218
Latest member
Excel Master

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