Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Passing a variable to a range statement

Please could you tell me the correct syntax to use in this bit of code where
I am trying to define a named range "Jobs" which is A1 to row number
NoOfRows. A macro recorded this bit of code below and I am trying to
replace the "R360" with something like RNoOf Rows. R&NoOfRows does not
work.

ActiveWorkbook.Names.Add Name:="Jobs", RefersToR1C1:="=sheet1!R1C1:R360C1"


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Passing a variable to a range statement

One way

Sub test()
Dim NoOfRows As Long
NoOfRows = 10
Range("a1:a" & NoOfRows).Name = "Jobs"
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Mervyn Thomas" wrote in message ...
Please could you tell me the correct syntax to use in this bit of code where
I am trying to define a named range "Jobs" which is A1 to row number
NoOfRows. A macro recorded this bit of code below and I am trying to
replace the "R360" with something like RNoOf Rows. R&NoOfRows does not
work.

ActiveWorkbook.Names.Add Name:="Jobs", RefersToR1C1:="=sheet1!R1C1:R360C1"




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Passing a variable to a range statement

Place the Sheet name also in the code

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message ...
One way

Sub test()
Dim NoOfRows As Long
NoOfRows = 10
Range("a1:a" & NoOfRows).Name = "Jobs"
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Mervyn Thomas" wrote in message ...
Please could you tell me the correct syntax to use in this bit of code where
I am trying to define a named range "Jobs" which is A1 to row number
NoOfRows. A macro recorded this bit of code below and I am trying to
replace the "R360" with something like RNoOf Rows. R&NoOfRows does not
work.

ActiveWorkbook.Names.Add Name:="Jobs", RefersToR1C1:="=sheet1!R1C1:R360C1"






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Passing a variable to a range statement

Try

ActiveWorkbook.Names.Add Name:="Jobs", RefersToR1C1:="=sheet1!R1C1:R" &
NoOfRows & "C1"

Steve

"Mervyn Thomas" wrote in message
...
Please could you tell me the correct syntax to use in this bit of code

where
I am trying to define a named range "Jobs" which is A1 to row number
NoOfRows. A macro recorded this bit of code below and I am trying to
replace the "R360" with something like RNoOf Rows. R&NoOfRows does not
work.

ActiveWorkbook.Names.Add Name:="Jobs", RefersToR1C1:="=sheet1!R1C1:R360C1"




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
Passing string as array variable (Pivot VBA) klingongardener Excel Discussion (Misc queries) 2 December 23rd 06 07:58 PM
Passing Variable Number of Arguments to a Sub blatham Excel Discussion (Misc queries) 4 December 10th 05 10:36 AM
Passing Variable to LINEST RW Excel Worksheet Functions 5 May 24th 05 07:00 PM
UserForm not passing Boolean variable Chip Pearson Excel Programming 2 July 19th 03 06:06 PM
Passing a value to a variable from Userform Neal Steiner Excel Programming 1 July 18th 03 09:12 PM


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