Cutting letters from alphanumeric cell entry, pasting to another cell

Assuming you’re working with the first sheet and you’re always stripping off the last two characters while leaving the first 5 characters, the following code will work:

Public Sub StripOff()
  Dim iRow as Integer
  iRow = 2       'Assuming row 1 is headers, else make this 1
  While Sheets(1).Range("I" + Cstr(iRow)).Value <> ""
    Sheets(1).Range("L" + CStr(iRow)).Value = Right(Sheets(1).Range("I" + Cstr(iRow)).Value, 2)
    Sheets(1).Range("I" + Cstr(iRow)).Value = Left(Sheets(1).Range("I" + Cstr(iRow)).Value, 5)
    iRow = iRow + 1
  Wend
End Sub

Leave a Comment