Home |
Search |
Today's Posts |
#1
|
|||
|
|||
What causes runtime error 1004?
I have a macro that consists of these 3 lines:
Sub Macro2() ActiveSheet.PageSetup.RightHeader = Range("TestNamedRange") End Sub It's meant to include the value of a textual named range in a header. This macro generates Runtime error 1004 Method 'range' of object '_global' failed What causes this error? I have tried different variations of declarations, searching this forum, and traded posts with Bob Phillips (no aspersions intended-I think the thread just faded) to no avail. Any ideas? |
#2
|
|||
|
|||
What causes runtime error 1004?
Open the Define Name dialog (Ctrl-F3 is the shortcut) and make sure the name
TestNamedRange appears and that it refers to a cell. -- Jim wrote in message oups.com... |I have a macro that consists of these 3 lines: | Sub Macro2() | ActiveSheet.PageSetup.RightHeader = Range("TestNamedRange") | End Sub | | It's meant to include the value of a textual named range in a header. | This macro generates | Runtime error 1004 | Method 'range' of object '_global' failed | | What causes this error? I have tried different variations of | declarations, searching this forum, and traded posts with Bob Phillips | (no aspersions intended-I think the thread just faded) to no avail. | Any ideas? | |
#3
|
|||
|
|||
What causes runtime error 1004?
Jim-
The named range had been set up as a variable, with a value applied to the named rather than referring to a range. When I changed it to refer to a range, the code worked: thanks! What is the syntax to apply the named range that has a forced value attached? Thanks for your help! |
#4
|
|||
|
|||
What causes runtime error 1004?
If you've created a name that refers to a string you can do this:
ActiveSheet.PageSetup.RightHeader = Evaluate(Names("HeaderString").Value) The Evaluate is to peal off the "=" and quotes you see around the definition of the name in the Define Name dialog. -- Jim wrote in message oups.com... | Jim- | The named range had been set up as a variable, with a value applied to | the named rather than referring to a range. When I changed it to refer | to a range, the code worked: thanks! | | What is the syntax to apply the named range that has a forced value | attached? | | Thanks for your help! | |
#5
|
|||
|
|||
What causes runtime error 1004?
That did it- thanks again!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime error | Excel Discussion (Misc queries) | |||
runtime error '6' overflow | Setting up and Configuration of Excel | |||
Runtime Error 9 | Excel Discussion (Misc queries) | |||
Excel help giving runtime error | Excel Discussion (Misc queries) | |||
Why do I get the runtime error message430 when I start my compute. | Setting up and Configuration of Excel |