Sorry got side tracked. I'll send you my file of what I did that's kind of similar so you can look over it while I try to think of how yours should be accomplished. If you could make like a 20-30 row spreadsheet with example starting data and finishing data so I can better visualize how to get it done that'd be great.
Sub slam()
Dim SR As Long, k As Long, q As Long, w As Long, x As Long
Sheets("Matching").Select
SR = Range("A" & Rows.Count).End(xlUp).Row
q = 1
w = 1
x = 1
k = 1
Dim n As Long, p As Long
n = 1
p = 1
Dim y As Long, m As Long
m = 1
Dim this As String, val As String, ure As Long
this = Range("P" & q).Value
val = Range("P" & (q + 1)).Value
For k = 1 To SR
Sheets("Matching").Select
w = (k - 1)
x = (k + 1)
x = Range("K" & x).Value
q = Range("K" & k).Value
Range("A" & k).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("HAHA").Select
Range("A" & n).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If w = 0 Then
Sheets("Matching").Select
Range("P" & k).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("HAHA").Select
Range("P" & n).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
p = n
End If
If w <> 0 Then
Sheets("Matching").Select
Dim Z As Long, l As Long
Z = Range("K" & w).Value
If q <> Z Then
Range("P" & q).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("HAHA").Select
Range("P" & n).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
p = n
Cells(p, 1).EntireRow.Insert shift:=xlUp
n = n + 1
p = p + 1
Sheets("Matching").Select
End If
ure = n
If x > (q + 1) Then
this = Range("P" & q).Value
val = Range("P" & (q + 1)).Value
If val = this Then
y = x - (q + 1)
For y = 1 To y
l = q + y
m = p - 1 + y
Sheets("Matching").Select
Range("P" & l).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("HAHA").Select
Range("P" & m).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If (Range("P" & m).Value <> Range("P" & (m + 1))) Then
Exit For
End If
Application.Wait Now + TimeValue("00:00:01")
Next y
End If
End If
End If
Application.Wait Now + TimeValue("00:00:01")
n = n + 1
If m >= p Then
p = m + 1
End If
If p > n Then
n = p
Cells(p, 1).EntireRow.Insert shift:=xlDown
n = n + 1
p = p + 1
End If
Sheets("Matching").Select
Next k
End Sub
Bookmarks