Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default how to name a range with vba?

Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default how to name a range with vba?

Hi

you need to Set a range
try

Private Sub CommandButton1_Click()
Dim myname As Range
Set myname = Range("b5:b25")
myname.Select
End Sub

S


Britt wrote:
Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt


  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how to name a range with vba?

ActiveSheet.Names.Add Name:="MyName", RefersTo:="=$B$5:$B$25"


Britt wrote:
Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt


  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default how to name a range with vba?

Sub NameRange()
Range("B5:B25").Select
ActiveWorkbook.Names.Add Name:="MyRange", RefersToR1C1:= _
"=Sheet1!R5C2:R25C2"
End Sub


Vaya con Dios,
Chuck, CABGx3



"Britt" wrote:

Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt



  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default how to name a range with vba?

Thanks to all ..

"CLR" schreef in bericht
...
Sub NameRange()
Range("B5:B25").Select
ActiveWorkbook.Names.Add Name:="MyRange", RefersToR1C1:= _
"=Sheet1!R5C2:R25C2"
End Sub


Vaya con Dios,
Chuck, CABGx3



"Britt" wrote:

Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt







  #6   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default how to name a range with vba?

You missed a double quote:

range("b5:b25).name="myname"
should be
range("b5:b25").name="myname"

Britt wrote:

Hi,

I want to name a range of cells with vba.
I tried: range("b5:b25).name="myname"

but this gives an error.

Thanks
Britt


--

Dave Peterson
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 04:06 AM.

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"