Consulting

Results 1 to 2 of 2

Thread: Solved: Help in finishing the code

  1. #1
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location

    Solved: Help in finishing the code

    hi I have this small for loop code

    [VBA] 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

    [/VBA]
    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)
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  2. #2
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    Hi I got it

    the mistake was in parenthesis

    [VBA] .Cells(i, "A") = Left(Range("A" & i).Value, Len(.Cells(i, "a")) - 2)
    [/VBA]
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •