Reputation: 169
I have a cell linked to my ComboBox that displays the dropdown value of the ComboBox.
In another cell, I have IF statements that swap out the numbers based on certain scenarios, like : =IF(E38=0,C37,E37)
I tried putting an IF statement where the ComboBox value appears, but, as you guessed, when I run a macro and the ComboBox has to display a new value, the formula is erased.
The Formula I was using was : =IF(E38=0,"ComboBox Value",E37)
where ComboBox Value was the name currently in the dropdown.
This didn't work. I know it won't work in the LinkedCell property either.
Is there a way to incorporate this using VBA or a formula or conditional formatting or something?
Upvotes: 0
Views: 3229
Reputation: 2282
I think that this small demo will point you in the right direction. When value in comboBox changes it will change value in cell of your choosing. ignore the debug.print statements and probably want to use the change event not the click event.
Private Sub ComboBox1_Click()
Debug.Print ("CHANGED")
End Sub
Private Sub ComboBox1_Change()
Debug.Print ("CHANGED2")
ActiveSheet.Cells(1, 1) = ComboBox1.Value
End Sub
Upvotes: 1
Reputation: 193
Sub ComboIf()
If Range("E38").Value = 0 Then Range("C2").Value = Range("C1") Else: Range("C2").Value = Range("E37") End If
End Sub
Upvotes: 1
Reputation: 149
Did you try =INDEX("Input range","Cell link") to get your "ComboBox Value"?
Upvotes: 1