variables puzzle (public, static, named ranges. How???)

wassita

New Member
Joined
Mar 13, 2011
Messages
13
Hi all,
I am working in a macro that has two parts. The first one (call it macro1) summarizes and organize the data and the second (call it macro2) update it according to the users wish. The first part is ready, but to successfully write the second part I need some object variables defined in macro1. Those variables are public but they are cleared when macro1 finishes. I have tried to use the instruction static and to name a range in excel. It didn’t work.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
The VBA doesn’t read the named range and doesn’t accept the instruction static to a public variable.<o:p></o:p>
I really don’t know how to solve it. I would appreciate any help I could get around this.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Describe the order of events ... do you run macro1 to completion and then try to run macro2? If so the Public variables will be available .... but NOT if you close the workbook between runs OR if you have any crash in VBA between runs. As for named ranges not being picked up ... that's not possible whatever occurs between runs ( apart from closing the workbook where the named range exists without saving ).
 
Upvote 0
Hi GlennUK.
Macro1 is run to completition, then macro2 is ran. The workbook is not closed but the object variables for macro2 are cleared. If i run macro2 before macro 1 is ended then the variables are there but it will not solve the problem I have...
 
Upvote 0
GlennUK, thanks for your help. You are right. when I was preparing the macros to post I understood. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Sometimes when you are tired you don’t see clearly. I had a problem evaluating a formula and I thought it was the variables…<o:p></o:p>
Thanks.<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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