MID and FIND function in vba
Hi Howard,
Am Sat, 4 Jun 2016 02:57:39 -0700 (PDT) schrieb L. Howard:
With my_Instr_Copy() code it errors wanting an Object or Variable set, tried many different sets, but don't see it.
Set aCity = Mid(aState, InStr(aState, " - ") + 3, 99)
aCity is a string and not an object.
try:
aCity = Mid(aState, InStr(aState, " - ") + 3, 99)
Sub Test()
Dim LRow As Long, i As Long
Dim varCity() As Variant, varTmp As Variant
With Sheets("Sheet1")
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
varTmp = .Range("A2:A" & LRow)
ReDim Preserve varCity(UBound(varTmp))
For i = LBound(varTmp) To UBound(varTmp)
varCity(i) = Split(varTmp(i, 1), " - ")(1)
Next
.Cells(.Rows.Count, 4).End(xlUp)(2).Resize(UBound(varCity) + 1) _
= Application.Transpose(varCity)
End With
End Sub
Regards
Claus B.
--
Windows10
Office 2016
|