LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find a string into another string

Your code will work if the string is found, but if not, it raises an error.
Instr as suggested by Jim Thomlinson would seem a better choice.

--
Regards,
Tom Ogilvy

"alondon" wrote in message
...
WorksheetFunction is an application object.

Try:

Sub test()

Dim KeyString As String

Dim Sentence As String

Dim Result As String

KeyString = "AAAA"

Sentence = "BBBB CCCC AAAA NNNN"


Result = Application.WorksheetFunction.Find(KeyString, Sentance)

If (Result < "") Then

MsgBox "KeyString exists within Senetence"

End If

End Sub

Cheers,

Allan P. London, CPA



"Maileen" wrote in message
...
Hi,

I would like to know if a String belongs to another string.

for example :
Dim KeyString as String
Dim Sentence as String
Dim Result as Interger

Result = worksheetFunction.Find(KeyString,Sentence)
if (Result<"") then
Msgbox "KeyString exists within Senetence"
EndIf

but it doesn't work.
i just want to check if my KeyString belongs to Sentence, that's all.
basically i store into Sentence the value of a cell.
thx

Maileen







 
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 String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
find string within other string Nir Excel Worksheet Functions 8 October 25th 06 11:27 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM


All times are GMT +1. The time now is 02:27 PM.

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

About Us

"It's about Microsoft Excel"