Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding substrings within a string

Sorry if this question seems trivial, but for the life of me, I can'
figure out how to search for something within a string.

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC"
I want to be able to search str2 and see if str1 exists within it.

Thanks in advanced

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Finding substrings within a string

H

Try
str1 = "ABc
str2 = "AAA AAB AAC ABC ABC

MsgBox InStr(1, str2, str1, 1

Ton

----- Gaston wrote: ----

Sorry if this question seems trivial, but for the life of me, I can'
figure out how to search for something within a string

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC
I want to be able to search str2 and see if str1 exists within it.

Thanks in advanced


--
Message posted from http://www.ExcelForum.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Finding substrings within a string

If Instr(str2, str1)0 then msgbox "found"

Robin Hammond
www.enhanceddatasystems.com

"Gaston " wrote in message
...
Sorry if this question seems trivial, but for the life of me, I can't
figure out how to search for something within a string.

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC"
I want to be able to search str2 and see if str1 exists within it.

Thanks in advanced.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding substrings within a string

dim str2 as string
dim str1 as string
dim iplace as integer
dim start as integer
start = 1
iplace = InStr(start,str2,str1)
if iplace = 0 then
'not found
else
' iplace is set the the beginning of the in str2
' where str1 is located
end if
-----Original Message-----
Sorry if this question seems trivial, but for the life

of me, I can't
figure out how to search for something within a string.

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC"
I want to be able to search str2 and see if str1 exists

within it.

Thanks in advanced.


---
Message posted from http://www.ExcelForum.com/

.

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
Finding the cell with a specified string Don Kline[_2_] Excel Worksheet Functions 4 March 31st 09 04:19 AM
finding a name in a string jay d Excel Worksheet Functions 1 June 12th 06 09:25 PM
finding what numbers are in a string (Day 2) David Excel Worksheet Functions 0 May 26th 05 10:10 PM
finding what numbers are in a string David Excel Worksheet Functions 3 May 26th 05 10:10 PM
Finding a string FRAN Excel Programming 2 September 24th 03 01:32 PM


All times are GMT +1. The time now is 02:14 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"