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

If I have a string called data that contains, for example, 12 characters how
can I find teh position of two charactors within it.

e.g the string is :
abhhsctdshhd

how can I find the position of 'ct' within it ?

any suggestions appreciated.

brian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Interogating a string within a Macro

On Tue, 27 Mar 2007 16:08:55 -0700, Brian Young
wrote:

If I have a string called data that contains, for example, 12 characters how
can I find teh position of two charactors within it.

e.g the string is :
abhhsctdshhd

how can I find the position of 'ct' within it ?

any suggestions appreciated.

brian



InStr Function

Returns a Variant (Long) specifying the position of the first occurrence of one
string within another.

Syntax

InStr([start, ]string1, string2[, compare])


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Interogating a string within a Macro

instr() should do it.

--
Tim Williams
Palo Alto, CA


"Brian Young" wrote in message ...
If I have a string called data that contains, for example, 12 characters how
can I find teh position of two charactors within it.

e.g the string is :
abhhsctdshhd

how can I find the position of 'ct' within it ?

any suggestions appreciated.

brian



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Interogating a string within a Macro

data = "abhhsctdshhd"
MsgBox InStr(data, "ct")

Regards,
Greg

"Brian Young" wrote:

If I have a string called data that contains, for example, 12 characters how
can I find teh position of two charactors within it.

e.g the string is :
abhhsctdshhd

how can I find the position of 'ct' within it ?

any suggestions appreciated.

brian

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
String functions in VB macro Aerojade Excel Discussion (Misc queries) 6 October 3rd 08 02:36 PM
Passing string as macro parameter kmbarz Excel Programming 1 November 20th 06 05:31 PM
interogating a worksheet Jag Excel Worksheet Functions 0 July 17th 06 05:03 PM
Edit String VB Macro Lunch Excel Programming 4 March 13th 06 09:20 AM
A Macro to replace a string in a cell with a string from another cell??? Plica05 Excel Programming 2 August 16th 05 09:23 AM


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