Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default how to give variable range

i need the code for doing this..please help
i= 2 to 20 (variable)
ActiveWorkbook.Names.Add Name:="abc", RefersTorange= cells(1,1),cells(i,1)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default how to give variable range

i = 5
Set myrange = Range("A1", Cells(1, i))
ActiveWorkbook.Names.Add Name:="abc", RefersTo:="=" & myrange.Address

"ezil" wrote:

i need the code for doing this..please help
i= 2 to 20 (variable)
ActiveWorkbook.Names.Add Name:="abc", RefersTorange= cells(1,1),cells(i,1)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default how to give variable range

Better to use an offset formula such as =offset($a$1,0,0,counta($a:$a)) but
to answer.

Sub namerng()
mc = "b"
lr = cells(Rows.Count, mc).End(xlUp).Row
Range(cells(1, mc), cells(lr, mc)).Name = "abc"
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ezil" wrote in message
...
i need the code for doing this..please help
i= 2 to 20 (variable)
ActiveWorkbook.Names.Add Name:="abc", RefersTorange=
cells(1,1),cells(i,1)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default how to give variable range


Range("A2").Resize(i - 1).Name = "abc"

--
__________________________________
HTH

Bob

"ezil" wrote in message
...
i need the code for doing this..please help
i= 2 to 20 (variable)
ActiveWorkbook.Names.Add Name:="abc", RefersTorange=
cells(1,1),cells(i,1)



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 to give values to a range? pemt Excel Discussion (Misc queries) 0 July 24th 09 04:14 AM
How to give a value to a range of data? pemt Excel Discussion (Misc queries) 0 July 21st 09 09:11 PM
Give a cell a name that is variable Neall Excel Worksheet Functions 0 June 5th 09 01:32 PM
automatic range - named range give me circular reference... George Thorogood Excel Discussion (Misc queries) 0 February 22nd 07 07:53 PM
Is there any way to give an dynamic name for a range? salut Excel Discussion (Misc queries) 1 December 7th 05 02:05 PM


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

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"