Finding a particular character in a string using VBA

  • Thread starter Thread starter marston.gould
  • Start date Start date
M

marston.gould

As it reads in the heading...

I tried to use Application.Find but that doesn't seem to be available.

I need to find the location of the first space in a character string.
Is there any easy way to do this?
 
Hi Marston,

Sub Tester()
Dim sStr As String
Dim pos As Long
sStr = "ABC DEF"
pos = InStr(sStr, " ")
MsgBox pos
End Sub
 
Application.Find is the VBA equivalent of going to the Edit menu and selecting
Find. As Norman says, you use Instr for the equivalent of the worksheet
function FIND.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top