From: tompl on 8 Apr 2010 11:40
I agree that the value of the cell makes a perfectly good “Global variable”.
I don't 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:
Dim strMode As String
strMode = ThisWorkbook.Worksheets("First Sheet").Range("A1").Value
If strMode = "test" Then
'Do what ya gotta do.
If strMode = "Live" Then
'Do what ya don't gotta do.
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
I hope this helps.
Prev: Macro to hide worksheet based upon text in the name
Next: Data summary