ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Interogating a string within a Macro (https://www.excelbanter.com/excel-programming/386176-interogating-string-within-macro.html)

Brian Young

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

Ron Rosenfeld

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

Tim Williams

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




Greg Wilson

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



All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com