clear textboxes based on selected two ComboBoxes together on userform

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
415
Office Version
  1. 2016
Platform
  1. Windows
Hello
I use theses codes
VBA Code:
Private Sub UserForm_Initialize()

  If ComboBox1.Value = and <> "" ComboBox2.Value <> "" Then
TextBox1.Value = ""
  TextBox2.Value = ""
  TextBox3.Value = ""
  end if 
End Sub


and

VBA Code:
Private Sub ComboBox1_Change()
 If ComboBox1.Value <> "" And ComboBox2.Value <> "" Then
 TextBox1.Value = ""
  TextBox2.Value = ""
  TextBox3.Value = ""
 
  End If
 
End Sub

VBA Code:
Private Sub ComboBox2_Change()
 If ComboBox2.Value <> "" And ComboBox1.Value <> "" Then
 TextBox1.Value = ""
  TextBox2.Value = ""
  TextBox3.Value = ""
 
  End If
 
End Sub
but doesn't work for me
my goal if I select items from two comboboxes should clear textboxes . if I select another item from combobox1 and the combobox2 is already selected item (not empty) then should clear all of textboxes ,if I select another item from combobox2 and the combobox1 is already selected item (not empty) then should clear all of textboxes .
any better way to do that
thanks in advance.
 
now I understood why the error because in my project will there is items in resource from windows properties
so I can't use LIST properties for combobox I have to fill the items in comboboxes manually with this way. it's not practical totally

so you say from the first time will clear, but what if select another item from combobox1 and the combobox2 is already filled ? does work too?
I see nothing here.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
based on OP
it works when select items from two both comboxes from the first time , but if I change selection another item from combobox1 and the combobox2 is already selected then doesn't clear textboxes .
 
Upvote 0
based on OP
it works when select items from two both comboxes from the first time , but if I change selection another item from combobox1 and the combobox2 is already selected then doesn't clear textboxes .
I wanted to see the code you're now using.
Not an explanation of the code you're using.
 
Upvote 0
I wanted to see the code you're now using.
the code in OP
Not an explanation of the code you're using.
I know if that work for you as you said based on the last explanation or not, but you don't answer me!:rolleyes:
 
Upvote 0
Perhaps you can use a file sharing offering to send us a link to your (sanitized) file so we might have a closer look? Right now this feels like a stab in the dark.
 
Upvote 0
well, this procedure should be in the end after another code to populate in textbox . after populate if I select combobox2 then should clear.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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