Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default substring operation

hi ,
is there a way to find the n'th instance of a substring in its
parent string ?

regards,
jana

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default substring operation

Hi, here are a couple of examples that may help ...


Sub FindReplaceNthVal()
Dim strLook As String
Dim strFind As String
Dim lngInst As Long
Dim strFinal As String
strLook = "again1again2again3again4again5again6again7aga in8"
strFind = "again"
lngInst = 4
strFinal = WorksheetFunction.Substitute(strLook, strFind, "", lngInst)
MsgBox strFinal
End Sub
Sub FindNthPosition()
Dim strLook As String
Dim strFind As String
Dim lngInst As Long
Dim lngPos As Long
Dim strFinal As String
Dim strWhole As String
strLook = "again1again2again3again4again5again6again7aga in8"
strFind = "again"
lngInst = 4
strFinal = WorksheetFunction.Substitute(strLook, strFind, "~", lngInst)
lngPos = InStr(1, strFinal, "~")
strWhole = Mid(strLook, lngPos, Len(strFind))
End Sub


HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)
To email, remove the NO SPAM. Please keep correspondence to the board, as
to benefit others.



"jana" wrote in message
oups.com...
hi ,
is there a way to find the n'th instance of a substring in its
parent string ?

regards,
jana



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
extracting substring Rajesh Excel Discussion (Misc queries) 3 January 7th 10 10:23 AM
substring Satyanaidu Excel Discussion (Misc queries) 2 September 11th 09 09:33 AM
Extracting a SubString Brian Excel Discussion (Misc queries) 4 June 28th 07 07:30 PM
Substring Ldyflyr Excel Discussion (Misc queries) 0 February 15th 07 03:16 PM
Substring Petya Excel Discussion (Misc queries) 0 February 15th 07 02:53 PM


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