ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FIND function not defined in macro (https://www.excelbanter.com/excel-programming/345095-find-function-not-defined-macro.html)

ac

FIND function not defined in macro
 
I am using the FIND function to find a character in a text string. I have to
find the state (CA, MA) etc and have a text string "Mps/Stpaul, MN ".
So if I can find the "," I can use the "Right/Left" function to determine
the state. The help says that this function exists but the compiler is
giving me an error message.

Rowan Drummond[_3_]

FIND function not defined in macro
 
Try the Instr function eg:
Sub test()
Dim str As String
Dim state As String
str = "Mps/Stpaul, MN "
state = Mid(str, InStr(1, str, ",") + 2, 2)
MsgBox state
End Sub

This is only going to work if your data is consistent e.g in your
example there are two spaces between the , and the state.

Hope this helps
Rowan

AC wrote:
I am using the FIND function to find a character in a text string. I have to
find the state (CA, MA) etc and have a text string "Mps/Stpaul, MN ".
So if I can find the "," I can use the "Right/Left" function to determine
the state. The help says that this function exists but the compiler is
giving me an error message.


Alvin

FIND function not defined in macro
 
it does exists.

MsgBox WorksheetFunction.Find(",", "ABCD,EFGH")
will give you 5

"AC" wrote:

I am using the FIND function to find a character in a text string. I have to
find the state (CA, MA) etc and have a text string "Mps/Stpaul, MN ".
So if I can find the "," I can use the "Right/Left" function to determine
the state. The help says that this function exists but the compiler is
giving me an error message.


sebastienm

FIND function not defined in macro
 
Hi,
1. Does it break on the
WorksheetFunction.Find
or on something else such as the Left/Right vba functions?
2. could you please post some of your code?

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"AC" wrote:

I am using the FIND function to find a character in a text string. I have to
find the state (CA, MA) etc and have a text string "Mps/Stpaul, MN ".
So if I can find the "," I can use the "Right/Left" function to determine
the state. The help says that this function exists but the compiler is
giving me an error message.



All times are GMT +1. The time now is 09:18 AM.

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