Question concerning VBA and Excel

  • Thread starter Thread starter ME
  • Start date Start date
M

ME

Is there a way to "disable" a portion of code (the code is not called from
a control or event, but from another section of code) prgramaticly (sp?)?

For example, suppose I have some code that forces a save when I close the
spreadsheet, saving a copy to a backup location and to the origianl
location. Is there a way to "turn off the code" in the copy saved to the
backup location USING CODE only?

Any help is appreciated.

Michael
 
Not unless you insert code inside the "close code" that determines when you
want the code to run.
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
http://www.r-cor.com
 
Michael,

You could have a Boolean variable, and if false, run the code. In your other
code, you could set the flag to stop that running.

Dim fBypass As Boolean

Sub Test()

fBypass = True
Test_Routine

....

fBypass = False

End Sub

Sub Test_Routine()
If Not fBypass Then
'run the code

End If

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Forgive me if this sounds naive, but I'm not sure what you mean.

Here's what I am trying to do, and why. (The why first) One of the
ladies that works in our office is VERY adept at screwing things up. (We
are using excel as a way to do timesheets, by the way.) To make things
easier, I have set it up so that when they do a save or backup, it saves
it to the local drive and a network drive (limited access to the folder).
She was able to screw THAT up by not saving or backing things up before
she "broke it", so I added a routine to make the backup when she closes
the workbook. Only problem is if we need to go into the backup to check
something...when we close it, it over-writes the CURRENT one also.

Maybe I could send you a copy of the code and see what you think... I'm
pretty new to this, and it was mostly a kludge to get it done (two system
crashes that took it all away, and the second time it was backed up to my
laptop...and IT crashed the same day :( First time I was dumb and didn't
back it up), but If you, or any one else, could let me know HOW to do it,
or where to look, I'd be more than glad to do the research. I just came
up blank on my attempts to find info.

______
Michael
 
Michael,

I gave you some ideas yesterday. If you want to send me a copy, and tell me
what you would not do, when, and how that is identified, I'll see what I can
do.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top