Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Having a problem using a variable to add a 'name'


Okay, to get this working I've had to change the davv... reference t
the actual worksheet name instead, like: 'Validation Values'!C1. Stil
can't understand why I can't just reference a variable but I need t
get the working. I'm sure it's something quite basic and fundamental i
relation to the way you should use/declare variables so I would stil
appreciate any advice to prevent similar issues in the future?

Thanks,

Adria

--
Kobayash
-----------------------------------------------------------------------
Kobayashi's Profile: http://www.excelforum.com/member.php...info&userid=87
View this thread: http://www.excelforum.com/showthread.php?threadid=27358

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Having a problem using a variable to add a 'name'

if davvsheet is a variable holding the text Sheet2

then

Sub BBTest()
Dim DAbook as Workbook
Dim davvsheet as String
davvsheet = "Sheet2"
Set DAbook = Workbooks("Book1.xls")
DAbook.Names.Add Name:="Lookuplist2", RefersToR1C1:= _
"=" & davvsheet & "!c1"
End Sub

would work, but you were already given that answer???

a possibibility is that the sheet name has a space in it. Then you would
need

"='" & davvsheet & "'!c1"

so the name will be enclosed in single quotes.
--
Regards,
Tom Ogilvy


"Kobayashi" wrote in message
...

Okay, to get this working I've had to change the davv... reference to
the actual worksheet name instead, like: 'Validation Values'!C1. Still
can't understand why I can't just reference a variable but I need to
get the working. I'm sure it's something quite basic and fundamental in
relation to the way you should use/declare variables so I would still
appreciate any advice to prevent similar issues in the future?

Thanks,

Adrian


--
Kobayashi
------------------------------------------------------------------------
Kobayashi's Profile:

http://www.excelforum.com/member.php...nfo&userid=871
View this thread: http://www.excelforum.com/showthread...hreadid=273587



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
Having a problem using a variable to add a 'name' Kobayashi[_49_] Excel Programming 1 October 29th 04 02:22 PM
Having a problem using a variable in Kobayashi[_48_] Excel Programming 1 October 29th 04 01:24 PM
Variable problem TC[_6_] Excel Programming 3 September 16th 04 09:39 PM
vba variable problem joao Excel Programming 3 December 15th 03 04:31 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


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