ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching for double quote in a string (https://www.excelbanter.com/excel-programming/306236-searching-double-quote-string.html)

Jeff Harbin[_4_]

Searching for double quote in a string
 
I've got a string that contains a double quote ("). It's a thickness
measurement in inches. I would like to extract everything in that string to
the left of - and including - the double quote.

I'm using the Left("String", characters) function to do this.
Unfortunately, the position of the double quote in the string changes so I
cannot hard code the number of characters in the Left function. I'm trying
to use the InStr function to programmically determine the double quote's
position and thereby determine the number of characters to return in the Left
function.

How do you tell the InStr function to search for a double quote since the
search argument is surrounded by a pair of double quotes.

Thanks

Jeff


Tom Ogilvy

Searching for double quote in a string
 
from the immediate window to demonstrate:

sStr = "abcd""""efgh"
? sStr
abcd""efgh
? instr(sStr,"""")
5
? Left(sStr,Instr(sStr,""""))
abcd"


--
Regards,
Tom Ogilvy

"Jeff Harbin" wrote in message
...
I've got a string that contains a double quote ("). It's a thickness
measurement in inches. I would like to extract everything in that string

to
the left of - and including - the double quote.

I'm using the Left("String", characters) function to do this.
Unfortunately, the position of the double quote in the string changes so I
cannot hard code the number of characters in the Left function. I'm

trying
to use the InStr function to programmically determine the double quote's
position and thereby determine the number of characters to return in the

Left
function.

How do you tell the InStr function to search for a double quote since the
search argument is surrounded by a pair of double quotes.

Thanks

Jeff




merjet

Searching for double quote in a string
 
How do you tell the InStr function to search for a double quote since the
search argument is surrounded by a pair of double quotes.


str1 = "aa" & Chr(34) & "bb"
iPos = InStr(str1, """")

This sets iPos to 3, which is what you want.

HTH,
Merjet




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

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