Do while not last row

  • Thread starter littleredhairedgirl
  • Start date
L

littleredhairedgirl

Here's a loop I'm trying to excute that moves items in a column into
rows. I can't figure out completely how to set the loop to go under
that last row.


Sub Macro100()
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
cnt = 4
Do While [not last row]
dst = cnt - 1
Range("A" & cnt).Select
Selection.Cut Destination:=Range("B" & dst)
Range("A" & cnt + 1).Select
Selection.Cut Destination:=Range("C" & dst)
Range("A" & cnt + 2).Select
Selection.Cut Destination:=Range("D" & dst)
Range("A" & cnt + 3).Select
Selection.Cut Destination:=Range("E" & dst)
Range("A" & cnt + 4).Select
Selection.Cut Destination:=Range("F" & dst)
Range("A" & cnt + 5).Select
Selection.Cut Destination:=Range("G" & dst)
cnt = cnt + 7
End


End Sub
 
L

littleredhairedgirl

Here's a loop I'm trying to excute that moves items in a column into
rows. I can't figure out completely how  to set the loop to go under
that last row.
Didn't get the Loop in there right...


Sub Macro100()

Dim a As Integer, x As Integer
cnt = 4
x = Cells(Rows.Count, "A").End(xlUp).Row
For a = 1 To x

dst = cnt - 1
Range("A" & cnt).Select
Selection.Cut Destination:=Range("B" & dst)
Range("A" & cnt + 1).Select
Selection.Cut Destination:=Range("C" & dst)
Range("A" & cnt + 2).Select
Selection.Cut Destination:=Range("D" & dst)
Range("A" & cnt + 3).Select
Selection.Cut Destination:=Range("E" & dst)
Range("A" & cnt + 4).Select
Selection.Cut Destination:=Range("F" & dst)
Range("A" & cnt + 5).Select
Selection.Cut Destination:=Range("G" & dst)
cnt = cnt + 7

Next a

End Sub
 
M

Mike H

Hi,

Maybe this

Sub Macro100()
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
dst = 3
For x = 4 To lngLastRow Step 7
Range("A" & x).Cut Destination:=Range("B" & dst)
Range("A" & x + 1).Cut Destination:=Range("C" & dst)
Range("A" & x + 2).Cut Destination:=Range("D" & dst)
Range("A" & x + 3).Cut Destination:=Range("E" & dst)
Range("A" & x + 4).Cut Destination:=Range("F" & dst)
Range("A" & x + 5).Cut Destination:=Range("G" & dst)
dst = dst + 1
Next
End


End Sub

Mike
 

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