View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default MID and FIND function in vba

Oops, forgot to remove the element returned from the original code.
Initially, that version assigned the city for each row. This version
loads each value into vTmp as corrected below...

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), " - ")

If vTmp(0) = sState Then .Cells(n + 1, 4) = vTmp(1)

Next 'n

End With
End Sub


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus