PDA

View Full Version : [SOLVED:] macro to create a range name



selfteaching
10-04-2018, 05:19 PM
Hi
I’m trying to open a spreadsheet and go to the last cell in A that has data and create a range name. (here)
That after another macro (macro1) delete the range name (here) and drop down one cell.
This is what I have: the part that range names the cell doesn’t work


Private Sub Worksheet_activate()

Range("A5").Select

ActiveWindow.FreezePanes = True
x = Range("a" & Rows.Count).End(xlUp).Row
Range("A" & x + 1).Select
ActiveWindow.ScrollRow = ActiveCell.Row - 8
ActiveCell.Offset(-1, 0).Range("A1").Select
' can't get this to work
ActiveWorkbook.Names.Add Name:="here"

Macro1
ActiveWorkbook.Names("here").Delete
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub

Mike

Paul_Hossler
10-04-2018, 06:13 PM
I changed the HTML tags in your post to CODE tags -- that's the icon [#] to use for macros, not the [<>] icon

I usually just do something like this





ActiveCell.Offset(-1, 0).Range("A1"). Name:="here"






I don't think you need the Range("A1")

selfteaching
10-06-2018, 05:47 AM
Thank you Paul_Hossler

mike