Searching through a string for a sub-string

nbannon

New Member
Joined
Aug 4, 2002
Messages
23
Hi,

I need to search through a string which is a whole bunch of xml code, for the substring "inititatingid", then return the start position of this sub-string. Any ideas on the VBA function that can do this.

e.g. If the string was "<transaction id>1234<initiatingid>5555<destination>usa", then I would like the function to return 21, as this is the start position of the sub-string "initiatingid".

Any help would be great

Cheers

Noel.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
woops, that example won't make sense. I was using xml tags. Revised example...
"transactionid:1234 initiatingid:5555 destination:usa"

for this example, I would like the function to return 20.

Hope that makes more sense
 
Upvote 0
This could be done in a formula...
unused_paygo_Last6M_23sep02-.xls
ABCD
1/transactionid/1234/initiatingid/5555/destination/usa22
2
3
4
5
Sheet2


Or am I being too simple minded? (changed the< etc in the sheet to / )

Paddy
This message was edited by PaddyD on 2002-09-22 21:50
 
Upvote 0
Try this;
Look up help on [InStr]


<pre/>
Sub Tester()

Const strVar As String = "transactionid:1234 initiatingid:5555 destination:usa"
Const strSearch As String = "initiatingid"

MsgBox InStr(strVar, strSearch)

End Sub
</pre>
 
Upvote 0
PaddyD,

Is there a VBA function that does the same thing? I will be searching through multiple strings, so I don't really want to be returning them all to the spreadsheet in order to use the formula

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top