Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Declaring a local variable once for all subs

Hi,
I'd like to declare a variable once in an referenced xla file, in a
way that all the individual subs in the referring workbook can give it
a local value.
Is this possible?

Regards, Poniente
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Declaring a local variable once for all subs

On 9/29/2011 4:11 AM, Poniente wrote:
Hi,
I'd like to declare a variable once in an referenced xla file, in a
way that all the individual subs in the referring workbook can give it
a local value.
Is this possible?
Regards, Poniente


The first answer posted on this page may work for you:

.... create a simple xla called George:
Public harry As Variant
Public Sub setHarry(x)
harry = x
End Sub
Public Function getHarry()
getHarry = harry
End Function
I installed the xla. Then I created Alice.xls with a text box that
called setHarry when it changed and a cell with =getHarry() in it. I
kept it really simple:
Private Sub TextBox1_Change()
Run "george.xla!setHarry", TextBox1
End Sub
I then made a copy of Alice.xls as Bob.xls and ran them both. As
expected, if either workbook changes Harry, both workbooks see the result.

If this approach will work for you and you don't need to set the
variable value from VBA you could try using a constant and assigning its
value in the xla file and removing the set... function.

Private Const harry as string = "abcde12345"

http://stackoverflow.com/questions/3...iple-workbooks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Declaring a local variable once for all subs

If you create a variable which is globally accessible it can only have
one value at any given time. If you need local values then you need
local declarations....

Tim

On Sep 29, 4:11*am, Poniente wrote:
Hi,
I'd like to declare a variable once in an referenced xla file, in a
way that all the individual subs in the referring workbook can give it
a local value.
Is this possible?

Regards, Poniente


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
Declaring subs Public vs Private Rick Excel Programming 9 December 19th 07 12:30 AM
Declaring a tab name as a variable timmulla Excel Programming 2 January 25th 07 05:16 AM
Declaring a tab name as a variable timmulla Excel Programming 0 January 25th 07 03:26 AM
How to declare a variable for several subs David Excel Programming 17 May 18th 05 06:38 PM
Declaring a variable? pgoodale[_4_] Excel Programming 2 January 2nd 04 03:26 PM


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