Looping through controls in UserForm
I'm trying to make a clearAll() function inside my UserForm which sets all the fields on the various MultiPages equal to "".
I have 4 fields on 7 pages of one MultiPage all named "cboCategory1", "cboArea2", etc...
So essentially, I'm wondering if I can turn these 28 lines of code into something more efficient.
Private Sub clearAllFields()
Me.cboCategory1 = ""
Me.cboArea1 = ""
Me.txtDetails1 = ""
Me.cboType1 = ""
Me.cboCategory2 = ""
Me.cboArea2 = ""
Me.txtDetails2 = ""
Me.cboType2 = ""
Me.cboCategory3 = ""
Me.cboArea3 = ""
Me.txtDetails3 = ""
Me.cboType3 = ""
Me.cboCategory4 = ""
Me.cboArea4 = ""
Me.txtDetails4 = ""
Me.cboType4 = ""
Me.cboCategory5 = ""
Me.cboArea5 = ""
Me.txtDetails5 = ""
Me.cboType5 = ""
Me.cboCategory6 = ""
Me.cboArea6 = ""
Me.txtDetails6 = ""
Me.cboType6 = ""
Me.cboCategory7 = ""
Me.cboArea7 = ""
Me.txtDetails7 = ""
Me.cboType7 = ""
End Sub
Posted Dec 23, 2019, 2:27 PM UTC · edited
35
For sure.
You'll have to test for type to ensure you don't try to clear the labels
Brilliant, I got by with this.
Thanks, Solution Verified!
You have awarded 1 point to fuzzius_navus
^I ^am ^a ^bot, ^please ^contact ^the ^mods ^for ^any ^questions.
Since using Name, you could have probably shortened it to: