Link to home
Start Free TrialLog in
Avatar of -Polak
-PolakFlag for United States of America

asked on

Resetting All UserForms in a Workbook to Blank

Hi Experts, I'm trying to figure out the best way to reset all of my userforms to blank/false values. Each userform has a "clear all" button built in that does this with that particular form; I've thought about making those subs public and unique and then calling each one of them via a Reset Button. But I don't know if this is the most efficient way. Let me know, thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of -Polak

ASKER

Hum, okay didn't know that existed, I'll add that to the code to get the UI piece of it sorted. However, on the back end these UserForms set a lot of named ranges to be their respective values. As such, each "Clear All" button in the UserForm's clear their linked named ranges if pressed.

Would it be "more correct" to Unload the userforms then simply add Range("linkednamedrange").Clear in the Reset Macro?
You should probably do both but in order to be sure I'd need to see the workbook and have instructions on how to get to the point where you want to "reset" the userform.
Avatar of -Polak

ASKER

Ended up going with something like this
Sub ResetFHAnalysisEngine()
Unload frmAircraftInventory
Unload frmAircraftUtilization
Unload frmGlobalSettings
Call ResetCosts
Range("SelectedFHAllocationMethod").Value = 0
Range("SelectedFY").Clear
Range("SelectedFHDataSource").Clear
Range("SelectedBudgetConstraint").Clear
Range("SelectedCPFHCalcMethod").Clear
Range("SelectedFHtoDistribute").Clear
Range("SelectedAssetUtilization").Clear
Range("SelectedAircraftInventory").Clear
Range("NeworUsed").Value = "New"
End Sub

Open in new window

Thanks Martin!
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015