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

Hi,

Im using If then else condition in a series of macros, where macros may call
one another.

I have created some boolean variables (defined as Public type) whose values
will determine (used in If condition) whether the macros specified will run
or not.

Presently once I have run the macro and exited out of it and if I go to the
worksheet and make some changes and then run the macro again, the macro
doesnt get executed because my if condition evaluates as false (Basically
anytime I make a change in the worksheet my If should evaluate to true
only - Im using worksheet_change event.). I found out that it happens
because of the boolean variables being defined as public they sort of retain
the value from the last running of the macro.(Is that possible?)

I want to know if I can kill the variable values (from the last run) so that
next time I make changes in the worksheet and run the macro my If condition
is not bypassed.

Regards,
Hari
India


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Kill variables

Just set them to false as the last thing your macro does or as the first
thing it does (which might be better).

bfirst = False
bdum = False

Yes, variables declared as public at the top of a general module will retain
their values until the workbook is closed or you do a reset in the VBE.
--
Regards,
Tom Ogilvy



"Hari" wrote in message
...
Hi,

Im using If then else condition in a series of macros, where macros may

call
one another.

I have created some boolean variables (defined as Public type) whose

values
will determine (used in If condition) whether the macros specified will

run
or not.

Presently once I have run the macro and exited out of it and if I go to

the
worksheet and make some changes and then run the macro again, the macro
doesnt get executed because my if condition evaluates as false (Basically
anytime I make a change in the worksheet my If should evaluate to true
only - Im using worksheet_change event.). I found out that it happens
because of the boolean variables being defined as public they sort of

retain
the value from the last running of the macro.(Is that possible?)

I want to know if I can kill the variable values (from the last run) so

that
next time I make changes in the worksheet and run the macro my If

condition
is not bypassed.

Regards,
Hari
India




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Kill variables

Hi Tom,

Thnx a lot for ur input. Im able to accomplish what i wanted.

A query, why is it that you are suggesting on setting the false value in the
starting of the macro to be better.

Would be grateful to learn the same.

Regards,
Hari
India

"Tom Ogilvy" wrote in message
...
Just set them to false as the last thing your macro does or as the first
thing it does (which might be better).

bfirst = False
bdum = False

Yes, variables declared as public at the top of a general module will

retain
their values until the workbook is closed or you do a reset in the VBE.
--
Regards,
Tom Ogilvy



"Hari" wrote in message
...
Hi,

Im using If then else condition in a series of macros, where macros may

call
one another.

I have created some boolean variables (defined as Public type) whose

values
will determine (used in If condition) whether the macros specified will

run
or not.

Presently once I have run the macro and exited out of it and if I go to

the
worksheet and make some changes and then run the macro again, the macro
doesnt get executed because my if condition evaluates as false

(Basically
anytime I make a change in the worksheet my If should evaluate to true
only - Im using worksheet_change event.). I found out that it happens
because of the boolean variables being defined as public they sort of

retain
the value from the last running of the macro.(Is that possible?)

I want to know if I can kill the variable values (from the last run) so

that
next time I make changes in the worksheet and run the macro my If

condition
is not bypassed.

Regards,
Hari
India






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Kill variables

Sounds like you want them initialized each time you start the procedure, so
to be sure, do it there. It is really up to you which is best - what gets
the job done?

--
Regards,
Tom Ogilvy


"Hari" wrote in message
...
Hi Tom,

Thnx a lot for ur input. Im able to accomplish what i wanted.

A query, why is it that you are suggesting on setting the false value in

the
starting of the macro to be better.

Would be grateful to learn the same.

Regards,
Hari
India

"Tom Ogilvy" wrote in message
...
Just set them to false as the last thing your macro does or as the first
thing it does (which might be better).

bfirst = False
bdum = False

Yes, variables declared as public at the top of a general module will

retain
their values until the workbook is closed or you do a reset in the VBE.
--
Regards,
Tom Ogilvy



"Hari" wrote in message
...
Hi,

Im using If then else condition in a series of macros, where macros

may
call
one another.

I have created some boolean variables (defined as Public type) whose

values
will determine (used in If condition) whether the macros specified

will
run
or not.

Presently once I have run the macro and exited out of it and if I go

to
the
worksheet and make some changes and then run the macro again, the

macro
doesnt get executed because my if condition evaluates as false

(Basically
anytime I make a change in the worksheet my If should evaluate to true
only - Im using worksheet_change event.). I found out that it happens
because of the boolean variables being defined as public they sort of

retain
the value from the last running of the macro.(Is that possible?)

I want to know if I can kill the variable values (from the last run)

so
that
next time I make changes in the worksheet and run the macro my If

condition
is not bypassed.

Regards,
Hari
India








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Kill variables

Hi Tom,

Both ways I seem to get the job done. (Hope I havent missed something !!)

I thought may be that when u said re-initialize in the starting was meant as
one of the programming nuggets.

Anyway thanx a lot.

Regards,
Hari
India

"Tom Ogilvy" wrote in message
...
Sounds like you want them initialized each time you start the procedure,

so
to be sure, do it there. It is really up to you which is best - what gets
the job done?

--
Regards,
Tom Ogilvy


"Hari" wrote in message
...
Hi Tom,

Thnx a lot for ur input. Im able to accomplish what i wanted.

A query, why is it that you are suggesting on setting the false value in

the
starting of the macro to be better.

Would be grateful to learn the same.

Regards,
Hari
India

"Tom Ogilvy" wrote in message
...
Just set them to false as the last thing your macro does or as the

first
thing it does (which might be better).

bfirst = False
bdum = False

Yes, variables declared as public at the top of a general module will

retain
their values until the workbook is closed or you do a reset in the

VBE.
--
Regards,
Tom Ogilvy



"Hari" wrote in message
...
Hi,

Im using If then else condition in a series of macros, where macros

may
call
one another.

I have created some boolean variables (defined as Public type) whose
values
will determine (used in If condition) whether the macros specified

will
run
or not.

Presently once I have run the macro and exited out of it and if I go

to
the
worksheet and make some changes and then run the macro again, the

macro
doesnt get executed because my if condition evaluates as false

(Basically
anytime I make a change in the worksheet my If should evaluate to

true
only - Im using worksheet_change event.). I found out that it

happens
because of the boolean variables being defined as public they sort

of
retain
the value from the last running of the macro.(Is that possible?)

I want to know if I can kill the variable values (from the last run)

so
that
next time I make changes in the worksheet and run the macro my If
condition
is not bypassed.

Regards,
Hari
India










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
Kill Macro Jeff Excel Discussion (Misc queries) 4 September 27th 06 04:33 PM
File kill help Marino13[_6_] Excel Programming 0 February 19th 04 01:40 PM
Kill Command JamieD[_3_] Excel Programming 3 January 30th 04 01:20 PM
kill worksheets portroe Excel Programming 2 January 25th 04 11:11 PM
AutoFill KILL Frustrated[_2_] Excel Programming 1 July 29th 03 04:40 PM


All times are GMT +1. The time now is 06:27 AM.

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"