View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Steven Steven is offline
external usenet poster
 
Posts: 3
Default Looping through rows and shifting certain contents

OK, I dug in a little more and came up with this solution. It's not a
super fast calculation, but it works faster than I could manually. I
may add something to it to only do the calcs on filtered rows or
something.

Sub MoveBadRows()

Range("aj2").Select

Do While Selection.Offset(0, -1) < ""

If IsEmpty(ActiveCell) Then
Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0,
-16)).Select
Selection.Cut Destination:=ActiveCell.Offset(0,
2).Range("A1:P1")
ActiveCell.Offset(1, 16).Select

Else: ActiveCell.Offset(1, 0).Select
End If
Loop

Range("ak2").Select
Do While Selection.Offset(0, -1) < ""

If IsEmpty(ActiveCell) Then
Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0,
-16)).Select
Selection.Cut Destination:=ActiveCell.Offset(0,
2).Range("A1:P1")
ActiveCell.Offset(1, 16).Select

Else: ActiveCell.Offset(1, 0).Select
End If
Loop


End Sub