ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help Compare string to Combo box!!! (https://www.excelbanter.com/excel-programming/400773-help-compare-string-combo-box.html)

[email protected]

help Compare string to Combo box!!!
 
How would you compare a variable to see if it was in a combobox??
I was Thinking maybe

If Variable = CboBox.Text but wouldnt that only compare it to the one
selected?


Charles Chickering

help Compare string to Combo box!!!
 
Try something like this:
Dim cnt as long
For cnt = 0 to CboBox.ListCount - 1
If Variable = CboBox.List(cnt) then
'Do Something
Else
'Do Something Else
End If
Next
--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

How would you compare a variable to see if it was in a combobox??
I was Thinking maybe

If Variable = CboBox.Text but wouldnt that only compare it to the one
selected?




All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com