Re: Cut and paste part of a string in VBA

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ron de Bruin (rondebruin_at_kabelfoon.nl)
Date: 05/07/04


Date: Fri, 7 May 2004 22:02:37 +0200

Try this

Sub test()
Dim cell As Range
For Each cell In Columns("J").Cells.SpecialCells(xlCellTypeConstants)
cell.Offset(0, 2).Value = Right(cell.Value, 2)
cell.Value = Left(cell.Value, Len(cell.Value) - 2)
Next
End Sub

-- 
Regards Ron de Bruin
http://www.rondebruin.nl
"noah >" <<noah.15wfj4@excelforum-nospam.com> wrote in message news:noah.15wfj4@excelforum-nospam.com...
> I have another code that does that same thing. But what I can't get it
> to do; is delete the second 2 from column "J". In other-words, I need
> column "J" to have only the far left remaining.
> If column "J" has "ABC1" in a string, final result should be: Column
> "J" = "AB" and column "L" = "C1".
> AND sometimes column "J" will have a 5 character string like "ABCD1".
> And then I still want column "L" to only have "D1" and column "J" =
> "ABC" in final result.
> I probably need to add another command to it......
> What do you think?
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>

Quantcast