ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using InStr with variables (https://www.excelbanter.com/excel-programming/426975-re-using-instr-variables.html)

Barb Reinhardt

Using InStr with variables
 
FWIW, if you'd put Option Explicit before your code, you would have known
that you didn't have intSearch declared as well.

"wthomas206" wrote:

How do I use the InStr function with variables?
Dim intStart as integer
Dim strSearch as string
Dim strSought as string

strSearch = Range("E2").Value 'Cell value is PO Box 111 LAKEBAYWA 98349
strSought = Range("F2").Value 'Cell value is LAKEBAY

intStart = InStr(intSearch, strSought) ' intStart returns 0




All times are GMT +1. The time now is 05:34 PM.

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