View Full Version : Combobox VBA update value worksheet
Hi all,
How can i change a value in a cell using a combobox in VBA userform?
I already created a group called scenario range ='INPUT ALG'!$D$34:$D$36
How can i select it in the vba combobox and then update the value in the already existing combobox on the excelsheet.
Admin
10-27-2012, 11:59 AM
Hi
Not sure what do you want.
To get the selected value, try
Private Sub ComboBox1_Change()
Dim lngIndex As Long
With Me.ComboBox1
lngIndex = .ListIndex
If Not lngIndex = -1 Then
MsgBox .List(lngIndex)
End If
End With
End Sub
I cant upload the file as it is trusted, but i try to explain it:
On worksheet dashboard i have on cell E1 a combobox that is listing 3 values. When changing the combobox value the data behind will change automatically. What i try to do is create a combobox in a userform VBA that is getting the values of the combobox in cell E1 and when picking one of those values updating the value of E1 with the selected value.
Admin
10-27-2012, 04:42 PM
Again not sure..
Private Sub ComboBox1_Change()
Dim lngIndex As Long
With Me.ComboBox1
lngIndex = .ListIndex
If Not lngIndex = -1 Then
[e1]= .List(lngIndex)
End If
End With
End Sub
Again not sure..
Private Sub ComboBox1_Change()
Dim lngIndex As Long
With Me.ComboBox1
lngIndex = .ListIndex
If Not lngIndex = -1 Then
[e1]= .List(lngIndex)
End If
End With
End Sub
Hi :D
Thanks for your help, worked exactly how it should be :).
Private Sub ComboBox1_Change()
Dim lngIndex As Long
With Me.ComboBox1
lngIndex = .ListIndex
If Not lngIndex = -1 Then
[DASHBOARD!C6]= .List(lngIndex)
End If
End With
End Sub
And i set the rowsource to Scenario.. works perfect.. Is there also a way to display the current value on loading the userform in the combobox?
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.