PC Review


Reply
Thread Tools Rate Thread

Creating NamedRanges with VBA

 
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
Im having difficulty in creating a named range programmatically and getting
it to appear in the goto box. The following code DOES create a named range,
but the refference has quotes around it and therefore does not appear in the
goto box.

Does anyone know what I am doing wrong ?

Dim mr As String
mr = "Sheet1!myRange3"
'Create Range
Call ThisWorkbook.Names.Add(Name:=mr, RefersTo:="Sheet1!$A$1:$C$3",
Visible:=True)



 
Reply With Quote
 
 
 
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
Sorry should have read


Dim mr As String
mr = "Sheet1!$A$1:$C$3",
'Create Range
Call ThisWorkbook.Names.Add(Name:="myRange", RefersTo:=mr,
Visible:=True)


"Goofy" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> Im having difficulty in creating a named range programmatically and
> getting it to appear in the goto box. The following code DOES create a
> named range, but the refference has quotes around it and therefore does
> not appear in the goto box.
>
> Does anyone know what I am doing wrong ?
>
> Dim mr As String
> mr = "Sheet1!myRange3"
> 'Create Range
> Call ThisWorkbook.Names.Add(Name:=mr, RefersTo:="Sheet1!$A$1:$C$3",
> Visible:=True)
>
>
>



 
Reply With Quote
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
ItsOK, I worked it out, there should have been an equal sign before the
reference


"Goofy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry should have read
>
>
> Dim mr As String
> mr = "Sheet1!$A$1:$C$3",
> 'Create Range
> Call ThisWorkbook.Names.Add(Name:="myRange", RefersTo:=mr,
> Visible:=True)
>
>
> "Goofy" <(E-Mail Removed)> wrote in message
> news:u$(E-Mail Removed)...
>> Im having difficulty in creating a named range programmatically and
>> getting it to appear in the goto box. The following code DOES create a
>> named range, but the refference has quotes around it and therefore does
>> not appear in the goto box.
>>
>> Does anyone know what I am doing wrong ?
>>
>> Dim mr As String
>> mr = "Sheet1!myRange3"
>> 'Create Range
>> Call ThisWorkbook.Names.Add(Name:=mr, RefersTo:="Sheet1!$A$1:$C$3",
>> Visible:=True)
>>
>>
>>

>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Oct 2006
Simpler


worksheets("Sheet1").Range("$A$1:$C$3").Name = "myRange"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Goofy" <(E-Mail Removed)> wrote in message
news:uye%(E-Mail Removed)...
> ItsOK, I worked it out, there should have been an equal sign before the
> reference
>
>
> "Goofy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Sorry should have read
> >
> >
> > Dim mr As String
> > mr = "Sheet1!$A$1:$C$3",
> > 'Create Range
> > Call ThisWorkbook.Names.Add(Name:="myRange", RefersTo:=mr,
> > Visible:=True)
> >
> >
> > "Goofy" <(E-Mail Removed)> wrote in message
> > news:u$(E-Mail Removed)...
> >> Im having difficulty in creating a named range programmatically and
> >> getting it to appear in the goto box. The following code DOES create a
> >> named range, but the refference has quotes around it and therefore does
> >> not appear in the goto box.
> >>
> >> Does anyone know what I am doing wrong ?
> >>
> >> Dim mr As String
> >> mr = "Sheet1!myRange3"
> >> 'Create Range
> >> Call ThisWorkbook.Names.Add(Name:=mr, RefersTo:="Sheet1!$A$1:$C$3",
> >> Visible:=True)
> >>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
Thanks bob


"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Simpler
>
>
> worksheets("Sheet1").Range("$A$1:$C$3").Name = "myRange"
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "Goofy" <(E-Mail Removed)> wrote in message
> news:uye%(E-Mail Removed)...
>> ItsOK, I worked it out, there should have been an equal sign before the
>> reference
>>
>>
>> "Goofy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Sorry should have read
>> >
>> >
>> > Dim mr As String
>> > mr = "Sheet1!$A$1:$C$3",
>> > 'Create Range
>> > Call ThisWorkbook.Names.Add(Name:="myRange", RefersTo:=mr,
>> > Visible:=True)
>> >
>> >
>> > "Goofy" <(E-Mail Removed)> wrote in message
>> > news:u$(E-Mail Removed)...
>> >> Im having difficulty in creating a named range programmatically and
>> >> getting it to appear in the goto box. The following code DOES create a
>> >> named range, but the refference has quotes around it and therefore
>> >> does
>> >> not appear in the goto box.
>> >>
>> >> Does anyone know what I am doing wrong ?
>> >>
>> >> Dim mr As String
>> >> mr = "Sheet1!myRange3"
>> >> 'Create Range
>> >> Call ThisWorkbook.Names.Add(Name:=mr, RefersTo:="Sheet1!$A$1:$C$3",
>> >> Visible:=True)
>> >>
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with creating query or creating report Need Help Microsoft Access Database Table Design 0 29th Apr 2008 02:22 AM
creating PDF from msword - I get error while creating bookmarks =?Utf-8?B?bWFyay1uZWVkcy1oZWxw?= Microsoft Word Document Management 1 1st Nov 2005 05:48 AM
Auto creating text fields when creating new slide. =?Utf-8?B?amFtZXM=?= Microsoft Powerpoint 1 16th Jun 2005 04:02 PM
ClearContents - Except NamedRanges Mike Fogleman Microsoft Excel Programming 8 2nd Sep 2004 01:19 AM
Walkthrough: Creating a Dist. App. - problems creating project =?Utf-8?B?R2FyeURvdE5ldA==?= Microsoft Dot NET 1 12th Aug 2004 03:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 AM.