Move cells

G

gary

If the first 11 characters in C2 = the first 11 characters in C1, how can I move the contents of C2 to D1?

Example:

C D
123456789-0
123456789-0
234567890-1
345678901-2
345678901-2
345678901-2
456789101-3
567890123-4

Result:

C D
123456789-0 123456789-0

234567890-1
345678901-2 345678901-2
345678901-2
345678901-2

456789101-3
567890123-4

(Col A has 30,000 cells containing data)
 
C

Claus Busch

Hi Gary,

Am Sun, 10 Feb 2013 05:47:14 -0800 (PST) schrieb gary:
If the first 11 characters in C2 = the first 11 characters in C1, how can I move the contents of C2 to D1?
C D
123456789-0
123456789-0
234567890-1
345678901-2
345678901-2
345678901-2
456789101-3
567890123-4

try:

Sub MoveItems()
Dim LRow As Long
Dim rngC As Range

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For Each rngC In Range("C2:C" & LRow)
If rngC.Offset(-1, 0) = "" Then
If Left(rngC, 11) = Left(rngC.Offset(-2, 1), 11) Then
rngC.Cut rngC.Offset(-1, 1)
End If
Else
If Left(rngC, 11) = Left(rngC.Offset(-1, 0), 11) Then
rngC.Cut rngC.Offset(-1, 1)
End If
End If
Next
End Sub


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top