Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
Comparing text strings Comparing columns with text Excel Worksheet Functions 5 November 28th 09 07:43 PM
Comparing text strings in cells Andy Excel Discussion (Misc queries) 0 January 11th 06 10:38 AM
Comparing text strings in cells Andy Excel Discussion (Misc queries) 0 December 7th 05 04:17 PM
Comparing slightly different strings theDude[_18_] Excel Programming 0 July 30th 05 12:55 AM


All times are GMT +1. The time now is 06:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"