Forum Discussion
PeterYac
Apr 24, 2020Copper Contributor
Assign a name to a range
I need help assigning a name to a range and would welcome some help. The data will vary in terms of number of rows and number of columns. Below is some of my code along with questions - any help...
Riny_van_Eekelen
Apr 27, 2020Platinum Contributor
PeterYac Not sure if this will work in your specific situation, but you might want to try a bit of code similar to below:
Selection.SpecialCells(xlCellTypeLastCell).Select
lRow = Selection.Row
lCol = Selection.Column
ActiveWorkbook.Names.Add Name:="NamedRng", RefersToR1C1:= "=Sheet1!R1C1:R" & lRow & "C" & lColIt will find the last cell in the worksheet and that define a named range from A1 (top left) to that cell (bottom right).
- PeterYacApr 28, 2020Copper Contributor