View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default A hard DO loop for me

Assuming that A7:K7 should be B7:K7, then

Dim i As Long

For i = 6 To 2 Step -2
Range("B" & i + 1 & ":K" & i + 1).Copy Destination:=Range("L" & i)
Range("B" & i + 1).EntireRow.Delete
Next i


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

wrote in message ...
Fellow coders,

I have large files of data where I need to
copy every other row alongside the initial
row, and then delete the rows that are
copied.

An example of the procedure's code, without
ANY loops whatsoever follows:

Range("B3:K3").Select
Selection.Copy
Range("L2").Select
ActiveSheet.Paste
Range("B5:K5").Select
Application.CutCopyMode = False
Selection.Copy
Range("L4").Select
ActiveSheet.Paste
Range("A7:K7").Select
Application.CutCopyMode = False
Selection.Copy
Range("L6").Select
ActiveSheet.Paste
Range("3:3,5:5,7:7").Select
Range("A7").Activate
Selection.Delete Shift:=xlUp

I absolutely cannot do this without loops,
as the code will exceed the maximum allowable
lines.

How do I set the DO loop variables to do this
kind of incremental, every other row, rearrange,
and then delete?

Thanks,

Bert Gold