I want to save selected combobox value as global variable and select row of selected value I have excel file, where i want to make caluclations based on inputs in sheet1 and data on sheet2. Inputs are provided by combobox1 (list of names from coluom A in sheet 2), combobox2(case yes/no) and combobox3 (values 1,2,3). After I select value in combobox1(for exsample: ABC which is value A7 from sheet2), I want to calculate from data in row 7 in sheet2:B7(sheet2) +C7(sheet2)combobox3 value+D7(sheet2)(combobox2(yes=2/no=0). can anyone help me with that?
Public SelectedComboBox1 As String
Public SelectedComboBox2 As String
Public SelectedComboBox3 As intiger
Public calculate2 As Integer
Private Sub ComboBox1_DropButtonClick()
Sheet1.ComboBox1.List = Sheet2.Range("A3:A46").Value
SelectedComboBox1 = Me.ComboBox1.Value
End Sub
Private Sub ComboBox2_DropButton()
With Me.ComboBox2
.AddItem "YES"
.AddItem "NO"
End With
SelectedComboBox2 = Me.ComboBox2.Value
End Sub
Private Sub ComboBox3_DropButton()
With Me.ComboBox3
.AddItem "1"
.AddItem "2"
.AddItem "3"
End With
SelectedComboBox3 = Me.ComboBox3.Value
End Sub
Public Sub Calculate2_click()
calculate2 = Sheet2.Range("B7") * Sheet2.Range("C7") * SelectedComboBox3+Sheet2.Range("D7")*??
Sheet1.Range("H10").Value = calculate2
End Sub
variable = combobox.value
to the OnChanged-event. – Johanness