PDA

View Full Version : Solved: Help in finishing the code



anandbohra
05-25-2008, 11:39 PM
hi I have this small for loop code

With Sheet7
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
.Cells(i, "A") = Left(Range("A" & i).Value, Len(.Cells(i, "a") - 2))
Next i

End With
Range("a1").Select


my object is to retain all the values except 2
like
if range a1 contains vbaexpressXY so output should be vbaexpress (remove xy)
for this excel code is =left(a1, len(a1)-2)
but help me for the same in VBA (highlighted code)

anandbohra
05-25-2008, 11:44 PM
Hi I got it

the mistake was in parenthesis

.Cells(i, "A") = Left(Range("A" & i).Value, Len(.Cells(i, "a")) - 2)