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

Hi
I would like to define a range like this:
rnga = Range("D61:D96", "D101:D136", "D141:D176").

So I can use it in a spreadsheet formula such as this formula typed into
cell D40:

[D40] = STDEVP(rnga)

I know I can use INSERT - NAME - DEFINE to define rnga but I would like
to be able to do this through VBA.

Is this possible ?

Thanks in advance

Andrew Bourke




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Naming a range

Sheets("whatever").Range("D61:D96, D101:D136, D141:D176").Name = "rnga"

Alan Beban

Andrew B wrote:

Hi
I would like to define a range like this:
rnga = Range("D61:D96", "D101:D136", "D141:D176").

So I can use it in a spreadsheet formula such as this formula typed into
cell D40:

[D40] = STDEVP(rnga)

I know I can use INSERT - NAME - DEFINE to define rnga but I would like
to be able to do this through VBA.

Is this possible ?

Thanks in advance

Andrew Bourke




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Naming a range

Andrew,.

the simplest way for you to figure this one out would be to use the macro
recorder. Here's a long winded version.

Sub NameRange()

Dim rngA As Range

Set rngA = Sheets(1).Range("D61:D96")
Set rngA = Union(rngA, Sheets(1).Range("D101:D136"))
Set rngA = Union(rngA, Sheets(1).Range("D141:D176"))

Sheets(1).Names.Add Name:=Sheets(1).Name & "!" & "RangeA", _
RefersToR1C1:=rngA

End Sub

Robin Hammond
www.enhanceddatasystems.com


"Andrew B" wrote in message
u...
Hi
I would like to define a range like this:
rnga = Range("D61:D96", "D101:D136", "D141:D176").

So I can use it in a spreadsheet formula such as this formula typed into
cell D40:

[D40] = STDEVP(rnga)

I know I can use INSERT - NAME - DEFINE to define rnga but I would

like
to be able to do this through VBA.

Is this possible ?

Thanks in advance

Andrew Bourke






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
Range naming Squeaky Excel Discussion (Misc queries) 2 December 29th 06 09:10 PM
Naming a range bob777 Excel Discussion (Misc queries) 1 February 1st 06 01:05 PM
VB Code Naming a Range (range changes each time) krazylain Excel Programming 4 May 15th 04 12:41 PM
Naming a Range jacqui Excel Programming 9 February 10th 04 10:55 AM
Naming a Range with VB Justin Excel Programming 2 December 1st 03 09:38 PM


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