A
Amoni
Hi!!
I´m having trouble with subtract the value of the current item in my
combobox, I´ve created an combobox with to items A and B in excel. Later I
need to reach the the choosen value. So how to i get the value that is
displayed in the combobox. Im using value now. But this gives me the offset
value doesnt change when I change comboitem.
Here is my code:
Sub testCombo()
Dim oWs As Worksheet
Dim oOLE As OLEObject
Dim combo As ComboBox
Set oWs = ActiveSheet
Dim cell As Range
'To set with a cell
With Range("F8")
Set oOLE =
ActiveSheet.OLEObjects.Add(ClassType:="Forms.combobox.1", _
Left:=.Left, Top:=.Top, Width:=.Width,
Height:=.Height)
.ShrinkToFit = False
.MergeCells = False
.WrapText = True
Set combo = oOLE.Object
combo.Font.Size = 8
combo.ForeColor = RGB(255, 255, 255)
combo.AddItem ("A")
combo.ForeColor = RGB(0, 0, 255)
combo.AddItem ("B")
combo.ListIndex = 0
combo.Placement = xlMoveAndSize
combo.PrintObject = True
End With
Set cell = Cells(13, 5)
MsgBox combo.Value
End Sub
...............................................
Can somebody plz help me, thx
I´m having trouble with subtract the value of the current item in my
combobox, I´ve created an combobox with to items A and B in excel. Later I
need to reach the the choosen value. So how to i get the value that is
displayed in the combobox. Im using value now. But this gives me the offset
value doesnt change when I change comboitem.
Here is my code:
Sub testCombo()
Dim oWs As Worksheet
Dim oOLE As OLEObject
Dim combo As ComboBox
Set oWs = ActiveSheet
Dim cell As Range
'To set with a cell
With Range("F8")
Set oOLE =
ActiveSheet.OLEObjects.Add(ClassType:="Forms.combobox.1", _
Left:=.Left, Top:=.Top, Width:=.Width,
Height:=.Height)
.ShrinkToFit = False
.MergeCells = False
.WrapText = True
Set combo = oOLE.Object
combo.Font.Size = 8
combo.ForeColor = RGB(255, 255, 255)
combo.AddItem ("A")
combo.ForeColor = RGB(0, 0, 255)
combo.AddItem ("B")
combo.ListIndex = 0
combo.Placement = xlMoveAndSize
combo.PrintObject = True
End With
Set cell = Cells(13, 5)
MsgBox combo.Value
End Sub
...............................................
Can somebody plz help me, thx