ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   comparing text strings (https://www.excelbanter.com/excel-programming/398011-comparing-text-strings.html)

CG Rosén

comparing text strings
 
Good morning Group,

In the code below there is problem with the validation.
The Listbox1.Value is a text string like "a" or "b" etc. The
c.Value looks sometimes like "a,b,c,d". How to find out that
the Listbox1.Value is a part of the c.Value text string.

Grateful for hints how to approach the problem.

CG Rosén

---------------------------------------------------------------------------------------

Dim c as Range

For Each c In Sheets("Sheet1").Range("A1:A100")

If c.Value = Me.ListBox1.Value Then

Item1 = c.Value
Item2 = c.Offset(0, 1).Value

UserForm1.ListBox2.AddItem Item1
UserForm1.ListBox2.List(ListBox1.ListCount - 1, 1) = Item2

End If

Next c




Stefi

comparing text strings
 
Try this:
If InStr(1, c.Value, Listbox1.Value) 0 Then

Regards,
Stefi


€žCG Rosén€ ezt Ã*rta:

Good morning Group,

In the code below there is problem with the validation.
The Listbox1.Value is a text string like "a" or "b" etc. The
c.Value looks sometimes like "a,b,c,d". How to find out that
the Listbox1.Value is a part of the c.Value text string.

Grateful for hints how to approach the problem.

CG Rosén

---------------------------------------------------------------------------------------

Dim c as Range

For Each c In Sheets("Sheet1").Range("A1:A100")

If c.Value = Me.ListBox1.Value Then

Item1 = c.Value
Item2 = c.Offset(0, 1).Value

UserForm1.ListBox2.AddItem Item1
UserForm1.ListBox2.List(ListBox1.ListCount - 1, 1) = Item2

End If

Next c





Bob Phillips

comparing text strings
 
If Me.ListBox1.Value Like "*" & c.Value & "*" Then

or

If Instr(c.Value, Me.ListBox1.Value) 0 Then

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"CG Rosén" wrote in message
...
Good morning Group,

In the code below there is problem with the validation.
The Listbox1.Value is a text string like "a" or "b" etc. The
c.Value looks sometimes like "a,b,c,d". How to find out that
the Listbox1.Value is a part of the c.Value text string.

Grateful for hints how to approach the problem.

CG Rosén

---------------------------------------------------------------------------------------

Dim c as Range

For Each c In Sheets("Sheet1").Range("A1:A100")

If c.Value = Me.ListBox1.Value Then

Item1 = c.Value
Item2 = c.Offset(0, 1).Value

UserForm1.ListBox2.AddItem Item1
UserForm1.ListBox2.List(ListBox1.ListCount - 1, 1) = Item2

End If

Next c






All times are GMT +1. The time now is 09:01 AM.

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