Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default 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   Report Post  
Jim Rech
 
Posts: n/a
Default 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   Report Post  
 
Posts: n/a
Default 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   Report Post  
Jim Rech
 
Posts: n/a
Default 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   Report Post  
 
Posts: n/a
Default What causes runtime error 1004?

That did it- thanks again!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime error Anthony Excel Discussion (Misc queries) 1 October 9th 05 01:28 AM
runtime error '6' overflow don Setting up and Configuration of Excel 1 July 26th 05 02:52 AM
Runtime Error 9 Lizz45ie Excel Discussion (Misc queries) 1 May 27th 05 08:44 PM
Excel help giving runtime error Hari Prasadh Excel Discussion (Misc queries) 1 January 21st 05 01:23 PM
Why do I get the runtime error message430 when I start my compute. Thorcat Setting up and Configuration of Excel 1 December 2nd 04 07:15 PM


All times are GMT +1. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"