Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Do while not last row

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Do while not last row

On Oct 24, 6:29*am, littleredhairedgirl
wrote:
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
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Do while not last row

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

"littleredhairedgirl" wrote:

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
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"