Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 342
Default Declaring variables for use in multiple worksheets

I agree that the value of the cell makes a perfectly good Global variable.
I dont see any advantage to the function and I would not bother with the
range name. The following is an example of how I might do it:

Sub testit2()

Dim strMode As String

strMode = ThisWorkbook.Worksheets("First Sheet").Range("A1").Value
If strMode = "test" Then
'Do what ya gotta do.
End If
If strMode = "Live" Then
'Do what ya don't gotta do.
End If

End Sub

I like the blnHasRun routine that Jim posted but would note two things:

1) Each time the workBOOK is opened it will be reset to False and run the
routine the first time the workSHEET is activated. If that is not desirable
you could use the value of a cell in the worksheet as the variable.

2) The code will need to be copied to each worksheet for which you want it
to apply.

I hope this helps.

Tom

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
LookUP function with multiple variables and worksheets mjwk Excel Worksheet Functions 1 March 18th 10 05:11 PM
Overflow error when declaring variables Jeff Excel Discussion (Misc queries) 2 January 9th 08 03:15 PM
Declaring variables in Module vs. Public Jeff Excel Discussion (Misc queries) 5 November 19th 07 08:27 PM
Declaring variables freekrill Excel Discussion (Misc queries) 2 July 19th 06 06:36 AM
Declaring variables freekrill Excel Discussion (Misc queries) 0 July 18th 06 06:15 PM


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