简体   繁体   中英

How to add excel vba combobox dependent on another combobox in Userform without affecting clear data function after click on save button

I trying to add combobox ("Product") dependent on another combobox ("Insurance Rate") in Userform. But after i add in this two combo box and try to click on "Command Button Save", the combox "Product" name still exist in the comboBox. By default before add in combobox ("Product") dependent on another combobox, it will reflect auto clear function after save command button.Hopefully someone can help to fix this issue, thank you very much. Below is the code. I have refer Me.cmbPro.Rowsource from worksheet "Product"

Private Sub cmbPro_Change()

Me.CmbIns = ""
Select Case Me.cmbPro
    Case "Product"
        Me.CmbIns.RowSource = "Product"
    Case "GAA"
        Me.CmbIns.RowSource = "GAA"
    Case "GPPS"
        Me.CmbIns.RowSource = "GPPS" 
    Case "Propylene"
        Me.CmbIns.RowSource = "Propylene"

End Select
End Sub

Clear the combo value with Me.cmbPro.Value = "" after your code, or in the save command button code:

Private Sub cmbPro_Change()

Me.CmbIns = ""
Select Case Me.cmbPro
    Case "Product"
        Me.CmbIns.RowSource = "Product"
    Case "GAA"
        Me.CmbIns.RowSource = "GAA"
    Case "GPPS"
        Me.CmbIns.RowSource = "GPPS" 
    Case "Propylene"
        Me.CmbIns.RowSource = "Propylene"

End Select
Me.cmbPro.Value = ""
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM