Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default refer to cell

Hi! I want to name a range in VBA. I know in what cell I want it to start,
lets say A1. I also have a variable that controls both the height and length
of the range (they are of equal size). This variable is called x.

I have:

ThisWorkbook.Names.Add Name:="CorrMatrix", RefersTo:="=$A$1:$C$10",
Visible:=True

but the Refers to bit is wrong. How shall I write it? please help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default refer to cell

Hi Anne,

Your question is not clear but, perhaps, try
something like:

'=============
Public Sub Tester()
Dim x As Long, y As Long
x = 6
y = 4
ThisWorkbook.Names.Add Name:="CorrMatrix", _
RefersTo:=Range("A1").Resize(x, y).Address
End Sub
'<<=============



---
Regards,
Norman



"Arne Hegefors" wrote in message
...
Hi! I want to name a range in VBA. I know in what cell I want it to start,
lets say A1. I also have a variable that controls both the height and
length
of the range (they are of equal size). This variable is called x.

I have:

ThisWorkbook.Names.Add Name:="CorrMatrix", RefersTo:="=$A$1:$C$10",
Visible:=True

but the Refers to bit is wrong. How shall I write it? please help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default refer to cell

Your RefersTo doesn't reference the sheet you are using. It should be
something like

"=Sheet1!$A$1:$C$10"

HTH,
Barb Reinhardt

"Arne Hegefors" wrote:

Hi! I want to name a range in VBA. I know in what cell I want it to start,
lets say A1. I also have a variable that controls both the height and length
of the range (they are of equal size). This variable is called x.

I have:

ThisWorkbook.Names.Add Name:="CorrMatrix", RefersTo:="=$A$1:$C$10",
Visible:=True

but the Refers to bit is wrong. How shall I write it? please help!

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
sql that will refer to a cell in excel zero6060 Excel Programming 1 August 17th 06 07:33 AM
Refer a specific cell in a named cell range [email protected] Excel Programming 2 March 13th 06 07:02 PM
How make hyperlink refer to cell content rather than cell address. Omunene Excel Discussion (Misc queries) 3 March 2nd 06 01:07 AM
How to refer to every 5 th cell? R.P.McMurphy Excel Discussion (Misc queries) 21 August 27th 05 06:13 PM
refer cell using c anupam Excel Programming 2 August 8th 04 03:24 AM


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