Strip single macro after running.

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
I have a workbook with many macros that need to run throughout the life of the workbook. However, I have one macro that runs on Workbook open that I only need for the initial run of the workbook. The workbook does an automatic saveas after the macro in question is run which gets me to a point where I no longer need/want the macro. Does anyone have a way to strip just that macro in question after it is run?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
Solved! Post subject: Strip single macro after running.

Problem Solved
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hi Joe,
Glad you got your problem solved.
Care to post what you did to solve it? I can think of a few ways to deal with something like
that but I'm sure somebody with a similar need searching through here in the future may be
able to benefit from what you've done.
 

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
Work around

The macro that I wanted to run only once was an Input box that wrote a text string to a cell. My work around was to write as follows:

Code:
Private Sub ****()
If IsEmpty("cell which the input box wrote the text string to")
 
"single run macro"
"other code"
Else

"other code"

End If
End Sub

I am sure there are many ways to deal with this problem. This way is pretty simple and works well.

Joe :LOL:
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Yep, that's about as simple as it gets and, (depending on the complexity of your
run-once code), would've been my first suggestion. :biggrin:

Thanks.
 

Forum statistics

Threads
1,136,349
Messages
5,675,244
Members
419,557
Latest member
razlevav

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
Top