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
self-sizing adv.filter criteria range BorisS Excel Discussion (Misc queries) 3 September 24th 06 01:30 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Wrap Text Across Columns & Rows Michael Excel Dude Excel Discussion (Misc queries) 1 September 4th 06 02:14 AM
Duplicate Range Names by worksheet FlaAl Excel Discussion (Misc queries) 0 May 24th 06 05:14 PM
Help with using range names in sum function soteman2005 Excel Worksheet Functions 2 November 28th 05 04:43 PM


All times are GMT +1. The time now is 10:12 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"