Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB Code Naming a Range (range changes each time)

Can somehere tell me how to name a range in excel using VB code. Here'
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 sam
name for whatever the range is?

Thanks..
Krazylai

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VB Code Naming a Range (range changes each time)


Selection.Name ="myRange"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB Code Naming a Range (range changes each time)

Thanks guys..

Never used this vb command before, but this is exactly what I wanted.

Selection.Name ="myRange"


Thanks..

Krazylai

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VB Code Naming a Range (range changes each time)

We aim to please.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"krazylain " wrote in message
...
Thanks guys..

Never used this vb command before, but this is exactly what I wanted.

Selection.Name ="myRange"


Thanks..

Krazylain


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



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
Assign a code to a range of time Elizabeth Excel Worksheet Functions 15 October 28th 07 06:42 PM
Naming a range with VBA... Steff_DK[_14_] Excel Programming 5 April 27th 04 03:55 PM
Naming a range cornishbloke[_5_] Excel Programming 1 December 15th 03 02:28 PM
Range naming BigJim Excel Programming 5 December 2nd 03 01:06 PM
Code for naming worksheet name range?? Sandy[_3_] Excel Programming 2 September 7th 03 04:49 AM


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