Macro to copy cells one row up then move down 4 rows & repeat

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a downloaded report that does not have data on one row. I need to
copy 5 cols. of data from one row to the row above then move 4 rows down and
repeat. I've done this with Lotus years ago, but never with Excel

Thanks,
 
If you mean you want to remove all blank rows in a report

Sub RemoveRows()
On Error Resume Next
Columns(1).SpecialCells(xlBlanks).EntireRow.Delete
On Error goto 0
End Sub
 
Josef,
Assuming you know where to start and when to stop, here's
an example that starts at row 2 and loops 3 times.
Geof.
Sub testcopy()

Dim lngCounter As Long
Dim lngCurrentRow As Long
Dim lngTotal As Long

lngCurrentRow = 2
lngTotal = 3

For lngCounter = 1 To lngTotal
Range("A" & lngCurrentRow, "E" &
lngCurrentRow).Copy Destination:=Range("A" &
lngCurrentRow).Offset(-1, 0)
lngCurrentRow = lngCurrentRow + 4
Next lngCounter

End Sub
 
Geof,

Thanks, it worked like great. I guess you can't copy macros into the macro
editor? I retyped it and worked.

Thanks again
 
Josef,
You're welcome. You should be able to copy & paste the
code. It might have some junk. I commented out many
statements. Longer lines had carriage returns when posted
You might have had the goofy >> characters.
Geof.
 

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

Back
Top