1

I have a combobox in the form of excel. What I need is when user click on combobox, code must remember the value that was in combobox to the first variable and then when user select new value code must remember the new value to the second variable. I've tries all scenarios like "DropButtonClick" etc.

Here is the code for combobox

ComboBoxDensityUpper.List = Array("kg/m3", "g/cm3", "SG")

Then I've tried this, but it saves the value that user select, not the value that was initially in combobox.

Private Sub ComboBoxDensityUpper_DropButtonClick()
   Dim FirstValue As String

    FirstValue = ComboBoxDensityUpper.Value

    MsgBox FirstValue
End Sub
CLR
  • 11,284
  • 1
  • 11
  • 29
  • First, I would make a habit of getting your list of [combobox values from a range](https://stackoverflow.com/a/14392365/4717755) on a worksheet. (You can hide this sheet if you want.) When you do this, you always know the "primary" value because it's the first value in the range. Plus, you can change the list without changing the VBA code. – PeterT May 18 '23 at 13:06
  • @PeterT not if you change `ListIndex` – Lord-JulianXLII May 18 '23 at 15:15

0 Answers0