View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
steveb[_4_] steveb[_4_] is offline
external usenet poster
 
Posts: 24
Default VB Code Naming a Range (range changes each time)

This could work:
ActiveWorkbook.Names.Add Name:="MyRange",
RefersToR1C1:=Sheets(ActiveSheet.Name).Range(Activ eCell.Address)

(watch for word-wrap, should be one line)

hth
--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"krazylain " wrote in message
...
Can somehere tell me how to name a range in excel using VB code. Here's
how I get the range:

Range("L1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


As u can see the range changes, but I would like to create the same
name for whatever the range is?

Thanks..
Krazylain


---
Message posted from http://www.ExcelForum.com/