Sub ScratchMacro()
Dim pStr1 As String
Dim pStr2 As String
pStr1 = "Always Vote Repulican"
pStr2 = "Vote"
MsgBox pStr2 & " begins at position " & InStr(pStr1, pStr2) _
& " of the string " & pStr1
End Sub
You can even use it to turn a false statement like pStr1 into a true
statement:
Sub ScratchMacro2()
Dim pStr1 As String
Dim i As Long
pStr1 = "Always Vote Republican"
i = InStr(pStr1, "Republican")
MsgBox left(pStr1, i-1), vbInformation
End Sub
Sub ScratchMacro2()
Dim pStr1 As String
Dim pTruth As String
Dim i As Long
pStr1 = "Always Vote Republican"
i = InStr(pStr1, "Republican")
pTruth = Left(pStr1, i - 1)
MsgBox pHalfTruth & ", but never for a Democrat", vbExclamation
End Sub
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.