View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Ramage[_2_] Dave Ramage[_2_] is offline
external usenet poster
 
Posts: 41
Default Looping through Ranges of Rows

Nile,

Try this. Start with the raw data sheet active, then run
the macro

Sub Make_Reports()

Dim iReport As Integer
Dim lRow As Long
Dim wsReport As Worksheet
Dim wsData As Worksheet

'speed things up a bit
Application.ScreenUpdating = False

iReport = 1
lRow = 2 'assumes first row is header row
Set wsData = ActiveSheet

Do While wsData.Cells(lRow, 1).Formula < ""
'add new worksheet for new report
Set wsReport = Worksheets.Add
wsReport.Name = "Report " & iReport
'copy headers
wsData.Range("A1:C1").Copy _
Destination:=wsReport.Range("A1")
'copy data (25 rows * 3 columns
wsData.Cells(lRow, 1).Resize(25, 3).Copy _
Destination:=wsReport.Range("A2")

iReport = iReport + 1
lRow = lRow + 25
Loop
End Sub

Cheers,
Dave
-----Original Message-----
Here is my case:
I get raw data from offices, which I have to simply

separate by
25 rows and make separate "nice" reports, for instance:

ID___NAME______AMOUNT

01---MIKE------$6600
XX---XXXX------$XXXX
91---JANET-----$4500

In the example above I have 91 rows of raw data.
If i did this manually I would have to make 4 reports out

of
this, because every nice report that I make is supposed

to have

25 records.

So how do I make a loop that will check every 25 row

range for
data, and if data was found then copy all 25 rows and

paste it on
a Report1, then check the next range from row 26 to 50.

Again if
there's anything then copy and paste it on Report2 sheet,

and so
on until the range has no data.

I would love to hear back from you on this matter,

Thanks a bunch,
Nile


.