Visual Basic Code in Excel Macro
-
Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:
Private Sub ComboBox1_Change()
ComboBox1.AddItem "SIDM"
ComboBox1.AddItem "BIJ"
ComboBox1.AddItem "M1D"
ComboBox1.AddItem "THERESA"
ComboBox1.AddItem "YS"
ComboBox1.AddItem "OPTION"
End SubBest Regards, Ahmad Rifai Yusuf
-
Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:
Private Sub ComboBox1_Change()
ComboBox1.AddItem "SIDM"
ComboBox1.AddItem "BIJ"
ComboBox1.AddItem "M1D"
ComboBox1.AddItem "THERESA"
ComboBox1.AddItem "YS"
ComboBox1.AddItem "OPTION"
End SubBest Regards, Ahmad Rifai Yusuf
I think you really need to think this one through. ComboBox Change event fires everytime there is a change to the contents of the ComboBox, and yet you are adding more items to the ComboBox every time it fires. This will set up a continuous loop, that will run forever. You need to fill the ComboBox only once, and then use the Change event to execute instructions against the selected item.
-
Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:
Private Sub ComboBox1_Change()
ComboBox1.AddItem "SIDM"
ComboBox1.AddItem "BIJ"
ComboBox1.AddItem "M1D"
ComboBox1.AddItem "THERESA"
ComboBox1.AddItem "YS"
ComboBox1.AddItem "OPTION"
End SubBest Regards, Ahmad Rifai Yusuf
You either need to make this a once only event, a simple flag and IF THEN would do it, or reset the combo box each time. Depending on what you need either is a valid option.
ComboBox1.Items.Clear()
would do the trick. Otherwise as I say just call the population once at the beginning.------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]