#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default constants

Hi, I'm using Worksheet_SelectionChange event in my workbook. On the very
begining of procedure I have some values initialized that I want to be
constants like this:

Dim x, y As String
x = "C1"
y = "H3"
...

I guess it's bad solution to have them initialized in the event procedure
because this way they get initialized every time event occurs. Where can I
put them to be initialized once and visible for Worksheet_SelectionChange
and other subs?
Shall I also set them at nothing and where when exiting workbook?
Thanx
alekmil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default constants

There shouldn't be any major penalty with initializing then in the Change
event since that is the only place they are used. When the change event
ends, they are destroyed, so there is no requirement to explicitly do
anything else to them.

Also, note that when you declare the type for a variable in VBA, you need to
declare the type for each variable.

Dim x, y as String

x is a variant
y is a string

Dim x as String, y as String
x is a string
y is a string

--
Regards,
Tom Ogilvy

"alekm" wrote in message
...
Hi, I'm using Worksheet_SelectionChange event in my workbook. On the very
begining of procedure I have some values initialized that I want to be
constants like this:

Dim x, y As String
x = "C1"
y = "H3"
...

I guess it's bad solution to have them initialized in the event procedure
because this way they get initialized every time event occurs. Where can I
put them to be initialized once and visible for Worksheet_SelectionChange
and other subs?
Shall I also set them at nothing and where when exiting workbook?
Thanx
alekmil



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
Constants in Excel Sharon Excel Discussion (Misc queries) 0 July 24th 08 02:38 PM
Range Name Constants veryeavy Excel Discussion (Misc queries) 2 July 2nd 08 02:23 AM
Constants In Formulae Barty Excel Discussion (Misc queries) 8 March 15th 07 09:00 PM
Flagging constants [email protected] Excel Worksheet Functions 2 April 3rd 06 07:42 PM
constants Confused Excel Discussion (Misc queries) 3 December 2nd 04 05:05 PM


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