Holding a variable in a dormant macro

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
15,507
Office Version
  1. 365
Platform
  1. Windows
Not sure if my title is misleading but didn't know how to refer to this problem.

I need to hold a variable (a) in a macro,

this needs the value of a = 0 when the workbook is opened

but needs to be changed to a=1 after the first run of the macro and retain this value for as long as the workbook remains open.

I'm guessing I'm going to feel rather stupid when someone gives me an answer that should have been obvious.:confused:

Thanks in advance.
 
Good to see you in here Mike, I think as always your answer has just solved many problems.

I've not come accross Static before but it sounds like what I need.

Thanks very much for your input :)
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
That looks like a better option Jindon,

I'm assuming that default would be Pubflag = False

In the code would "If PubFlg Then" Mean "If Pubflg = True" or "If Pubflg = False"?

Sorry for so many questions but not used this before.

Thanks again.

Correct.
 
Upvote 0
Thanks to all for their help and input on this, now managed to finish what I was trying :)

For anyone interested, I now have code that simulates excel 07's group function, with the expand / collapse link on the visible cell above the hidden range.

Seems a bit more user friendly than the built in version, and as far as I can see works on 03 as well, maybe older versions too.

Still has a few limitations but I'll be working on those later.

I'm sure it's been done before but when I was discussing it with others a while ago the general opinion was "not possible"

Nice to prove the sceptics wrong :)
 
Upvote 0

Forum statistics

Threads
1,222,907
Messages
6,168,963
Members
452,228
Latest member
just4jeffrey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top