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

Can anyone tell me what keyword I need to use to declare a
variable which will remain in scope while ever a workbook
is open. I know I've used this sometime ago but can't
think how I did it.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Variable scope

Hi TonyM,

Can anyone tell me what keyword I need to use to declare a
variable which will remain in scope while ever a workbook
is open. I know I've used this sometime ago but can't
think how I did it.


In a normal module, declare a variable as public in the top of the
module. It will be available to each module in the project.

Public sAppname As String= "The Name Of This Application"

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Variable scope

Hi Jan

Actually what I meant was if I declare a variable with
public scope and set it to an initial value which may then
change, how do I get the variable to retain the current
value while ever the workbook is open, ie outside of code
execution.

I could update a cell in Excel to do this but I'm sure
there is a way to do it within the code itself.

Thanks.


-----Original Message-----
Hi TonyM,

Can anyone tell me what keyword I need to use to

declare a
variable which will remain in scope while ever a

workbook
is open. I know I've used this sometime ago but can't
think how I did it.


In a normal module, declare a variable as public in the

top of the
module. It will be available to each module in the

project.

Public sAppname As String= "The Name Of This Application"

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Variable scope

Hi,
I used the names collection to store a variable.
Not secured by it works

Set the value
ActiveWorkbook.Names.Add Name:="SdbNumber", RefersToR1C1:="=" & txtSdb
get the value

Dim strSDB As String
strSDB = Application.Names("SdbNumber").Value
txtSdb = Mid(strSDB, 2, Len(strSDB) - 1)

HTH
regards,

JY
wrote in message
...
Hi Jan

Actually what I meant was if I declare a variable with
public scope and set it to an initial value which may then
change, how do I get the variable to retain the current
value while ever the workbook is open, ie outside of code
execution.

I could update a cell in Excel to do this but I'm sure
there is a way to do it within the code itself.

Thanks.


-----Original Message-----
Hi TonyM,

Can anyone tell me what keyword I need to use to

declare a
variable which will remain in scope while ever a

workbook
is open. I know I've used this sometime ago but can't
think how I did it.


In a normal module, declare a variable as public in the

top of the
module. It will be available to each module in the

project.

Public sAppname As String= "The Name Of This Application"

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Variable scope

Hi Jan

Ignore the last post - what you said is exactly what I was
after. Didn't think it was so straightforward !

Much appreciated.


-----Original Message-----
Hi Jan

Actually what I meant was if I declare a variable with
public scope and set it to an initial value which may

then
change, how do I get the variable to retain the current
value while ever the workbook is open, ie outside of code
execution.

I could update a cell in Excel to do this but I'm sure
there is a way to do it within the code itself.

Thanks.


-----Original Message-----
Hi TonyM,

Can anyone tell me what keyword I need to use to

declare a
variable which will remain in scope while ever a

workbook
is open. I know I've used this sometime ago but can't
think how I did it.


In a normal module, declare a variable as public in the

top of the
module. It will be available to each module in the

project.

Public sAppname As String= "The Name Of This Application"

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

.

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Variable scope

Actually what I meant was if I declare a variable with
public scope and set it to an initial value which may then
change, how do I get the variable to retain the current
value while ever the workbook is open, ie outside of code
execution.


Same method:

Public sAppname As String

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.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
Generic questions about variable scope the Initialize event TBA[_2_] Excel Programming 4 January 12th 04 03:42 PM
Variable scope question w/combo-box, 2ND try Tim Coddington Excel Programming 2 December 20th 03 04:07 AM
Variable scope question w/combo-box Tim Coddington Excel Programming 4 December 17th 03 02:38 AM
Scope of a public variable Jos Vens Excel Programming 0 November 24th 03 10:08 AM
Scope of Public Variable Dkline[_2_] Excel Programming 9 October 22nd 03 04:53 PM


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"