View Full Version : Solved: (location) inside of the combobox
white_flag
04-07-2010, 01:52 AM
good morning
I have an combobox with some text values inside. It is possible to find position(location) inside of the combobox on teh text value?
ex.
if
combobox1 = (location1) then Formula1
combobox1 = (location2) then Formula2
...
etc
Bob Phillips
04-07-2010, 03:02 AM
Why not just test the value
With Me.Combobox1
If .Value = "Value1" Then
action1
ElseIf .Value = "Value2" Then
action2
'etc
End If
End With
white_flag
04-07-2010, 04:05 AM
thx xld
With Me.ComboBox1
If .ListIndex = "0" Then
Cells(10, strLastCol + 1).Value = "=" & ActiveCell.Offset(1, 0).Address(True, False) & "*" & ActiveCell.Offset(2, 0).Address(True, False)
End If
etc...
End With
Bob Phillips
04-07-2010, 05:02 AM
If you are going to test ListIndex (which I think is a bad idea, value is better), it is a number so don't enclose the value in quotes.
mdmackillop
04-07-2010, 06:06 AM
Why not
Private Sub ComboBox1_Click()
Select Case ComboBox1.ListIndex
Case 1
'do stuff
Case 2
'do stuff
Case 3
'do stuff
End Select
End Sub
white_flag
04-07-2010, 07:52 AM
thx mdmackillop and xld
Select Case is a better choice.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.