LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default adding a VBA name to workbook names collection

The reason for the error probably is that you haven't set the variable name
to that range yet. Look at this code. This code sets the variable name to
the range in this line:
Set MyVBAVar = Range("A1:C5")
If the range is already named (worksheet name), say FirstDoodle, then you
can set the variable either with the above line or with this line:
Set MyVBAVar = Range("FirstDoodle")
But the variable must be set (defined) before you can apply a name to that
range by using the variable name.
The two message boxes display the addresses of the MyVBAVar range and the
"Doodle" range. They should be the same address. Otto

Sub TestNames()
Dim MyVBAVar As Range
Set MyVBAVar = Range("A1:C5")
'Above sets the variable name
'It does NOT name the range.
MsgBox "MyVBAVar address is: " & _
MyVBAVar.Address(0, 0)
MyVBAVar.Name = "Doodle"
'Above DOES name the range
MsgBox "The Doodle address is: " & _
Range("Doodle").Address(0, 0)
End Sub

"brachistochrone"
<brachistochrone.27l7bm_1147256701.4249@excelfor um-nospam.com wrote in
message news:brachistochrone.27l7bm_1147256701.4249@excelf orum-nospam.com...

Hi again,

I tried using the MyVBAVar.Name="Doodle" command that you suggested to
name the VBA variable rng_MXGdata as "rng_MXGdata".
So I was using:

rng_MXGdata.Name="rng_MXGdata"

I get the following error window:
Run-time error '424'
Object required

Do you know what the problem is? The only time the VBA variable appears
before the naming line is in:

rng_MXGdata=[rng_MXGdataSemiAnnual]

I have checked the VBA variable rng_MXGdata in the watch window and the
data seems to be in there.
Any idea what is going on?
Thanks for your help.

Edward


--
brachistochrone
------------------------------------------------------------------------
brachistochrone's Profile:
http://www.excelforum.com/member.php...o&userid=34274
View this thread: http://www.excelforum.com/showthread...hreadid=540353





 
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
Adding a collection to a wksht CLamar Excel Discussion (Misc queries) 1 June 23rd 06 04:31 PM
Adding to a Collection Cody Excel Programming 0 September 2nd 05 07:08 PM
code to add a name to the names collection and assign a reference keithb Excel Programming 2 August 5th 05 06:38 AM
Adding Range to Worksheet Names Collection Keith Willshaw Excel Programming 2 March 5th 04 09:17 AM
Names Collection MarkC[_2_] Excel Programming 2 January 28th 04 10:47 AM


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

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

About Us

"It's about Microsoft Excel"