MID and FIND function in vba
Hi Garry,
I get a Type Missmatch on the vTmp(1). The value of vTmp in the Dim statement shows correctly, as does the = vTmp in the code, with the (1) removed.
vTmp(1) = type missmatch
vTmp = "Greybull" but still type missmatch
Howard
'/ revised Garry
Sub my_Instr_Copy_Garry_2()
Dim sState$, vData, vTmp, n&
vData = Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
With Sheets("Sheet1")
sState = .Cells(1, 8).Value
For n = 1 To UBound(vData)
vTmp = Split(vData(n, 1), " - ")(1)
If vTmp(0) = sState Then .Cells(n + 1, 4) = vTmp(1)
Next 'n
End With
End Sub
|