Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Okay, this is my first post to this group, so I will try to be as complete
and precise as I can. Here's the VBA code as it is written... Sub Named_Range_Test() ' ' Named_Range_Test Macro ' Macro recorded 2/29/2004 by (name removed) ' Dim RangeName As String RangeName = ActiveSheet.Name Range("D13").Activate ActiveWorkbook.Names.Add Name:=RangeName, RefersToR1C1:= _ "='" & RangeName & "'!RC:R[956]C[6]" Range("A14").Activate End Sub Okay, now. That macro creates a named range from cell D13 to J969 inclusive and assigns the sheet's name to this range. No big deal right? Go ahead and try it. It'll work just fine the first time. Let's say you have a sheet named "Test1". You run this macro and, low and behold, there's a named range called "Test1" in your drop-down list up in the top left corner of the spreadsheet (works as it should). Well, that's just fine and dandy... except... Click on cell D13 and then select the named range from the drop-down. Looks fine, right? Great. Now select cell A1 and choose the named range from the drop-down list again... see what I mean? For some reason, the named range has been completely redefined using the relative references that were written in the macro, this time based on cell A1. (But the macro wasn't re-run was it?) Try choosing cell B9 and select from the drop-down again. See? What the ???? Any clues? How do I write the code using absolute references? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem creating named ranges in a Macro! | Excel Discussion (Misc queries) | |||
Creating dynamic ranges which are named. | Excel Worksheet Functions | |||
Macro (Print) - Calling Named Ranges | Excel Discussion (Misc queries) | |||
Creating dymnamic named ranges | Excel Programming | |||
Creating Named Ranges in VBA | Excel Programming |