VBA - Reset Combobox\Textbox on another combobox selection

Cred69

New Member
Joined
Jan 8, 2015
Messages
20
I have combobox13 and textbox14 that reflects the combobox13 selection. I have another combobox1 and when I select "D18", Combobox13 uses a named field from my spreadsheet. If anything else is selected it uses a different defined field. However, I need it to first clear out what is in the combobox13 first, otherwise, the users will not realize the options in combobox13 are incorrect.

Within the same file, I had a solution for another set of comboboxes, but I have been unable to reuse it. I am pretty sure this is that code:

Code:
With Me      
         .ComboBox2.ListIndex = -1 = .ComboBox1.ListIndex <> -1
        .ComboBox2.ListIndex = -1 = .TextBox2.Value = ""
End With


I came up with a different solution, but when I selected my button to write all the data from the textboxes to the spreadsheet Combobox13 and textbox14 went back to "". I had to remove that code, but I still don't have a solution to clear out the two boxes.

I am using some serious Nooby code because after all, I am a noob.

Code:
Private Sub ComboBox1_Change()

'Engine Designation
x = ComboBox1.Text
TextBox1.Value = x

'load combobox 13 per the selection of Combobox 1


            If ComboBox1.Value = "D18" Then
                ComboBox13.RowSource = "All_Panels"
    
            ElseIf ComboBox1.Value = "D24" Then
                ComboBox13.RowSource = "Panels"
    
            ElseIf ComboBox1.Value = "D34 - 74hp" Then
                ComboBox13.RowSource = "Panels"
    
            ElseIf ComboBox1.Value = "D34 - 130hp" Then
                ComboBox13.RowSource = "Panels"


            End If
    
End Sub



Private Sub ComboBox13_Change()


'Panel Model #


If TextBox14 = "MLC380 Panel\Harness" Then
    TextBox16.Value = "-"


    ElseIf ComboBox1.Value = "D18" Then
    TextBox16.Value = "32-00-0197"
    
    ElseIf ComboBox1.Value = "D24" Then
    TextBox16.Value = "32-00-0197"
    
    ElseIf ComboBox1.Value = "D34 - 74hp" Then
    TextBox16.Value = "32-00-0173"
    
    ElseIf ComboBox1.Value = "D34 - 130hp" And TextBox2.Value = "DL03-LER05" Then
    TextBox16.Value = "32-00-0201"
    
    ElseIf ComboBox1.Value = "D34 - 130hp" And TextBox2.Value = "DL03-SAR11" Then
    TextBox16.Value = "32-00-0201"
    
    ElseIf ComboBox1.Value = "D34 - 130hp" And ComboBox2.Value = "DL03-LEG01" Then
    TextBox16.Value = "32-00-0173"
        
End If


Pa = ComboBox13.Text
TextBox14.Value = Pa
  
End Sub

'Panel Model
Pa = ComboBox13.Value
Range("B68").Value = Pa

Private Sub CommandButton1_Click()

Pa = ComboBox13.Value
Range("B68").Value = Pa


ComboBox13.Value = ""
ComboBox13.RowSource = ""
TextBox14.Value = ""

End Sub

Any suggestions? I have searched the web and I have been unable to find exactly what I am looking for.

Sincerely,
Scott
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
NO sooner than I posted this I think I found my solution.

Code:
Private Sub ComboBox1_Change()

    With Me
        .ComboBox13.ListIndex = -1 = .ComboBox1.ListIndex <> -1
    End With

Private Sub ComboBox2_Change()


    With Me
        .ComboBox13.ListIndex = -1 = .ComboBox2.ListIndex <> -1
    End With

At the moment it seems to be working.
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,601
Members
449,520
Latest member
TBFrieds

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