Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Define Name on a changing selection of cells
I am trying to write a macro that uses Define Name to name a range of cells.
The range is always changing as rows and columns get added/deleted, so I tried using 'Selection.End' functionality. However, when it gets to RefersTo in Define Name, it hard codes the range instead of using the currently selected range. Any thoughts? Thanks! Sub Naming() ' ' Naming Macro ' ' Range("B4").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select ActiveWorkbook.Names.Add name:="Timeline", RefersToR1C1:= _ "=Timeline!R4C2:R49C66" ActiveWorkbook.Names("Timeline").Comment = "" Range("B2").Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trying to define a changing range for chart | Charts and Charting in Excel | |||
Problem with Cells Selection through macro. | Excel Programming | |||
Macro to select cells and then new selection from selected cells | Excel Programming | |||
How to automatically clear cells upon changing/making selection? | Excel Programming | |||
cells not changing selection after sheets array | Excel Programming |