Trying to figure a VBA double loop out

szita2000

Board Regular
Joined
Apr 25, 2012
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Hi Guys.

I have a sheet with Raw data dumped in. (ever changing number of rows)
I need to break this raw data out to printable templates. (Not simple headers but a silly sign off sheet. - otherwise I would try to print titles)


What I did is to make 10 worksheets with empty templates where I increased the number of empty template sheets. (First sheet is 1 page template, second is 2 sheets and so on)

I am stuck with the part where I take the raw data from row 2 to lastrow on the raw data sheet, offset a range with 18 rows then copy it across the correct sheet to the correct place.

I can't figure out how to use loop and/or offset maybe on the raw data page to jump by 18 rows rows but paste it to rows 9:26 then to 41:58 then to 72:89 and so on.

I managed to determine the number of sheets I need by this:

Code:
Public TemplatePage As Integer
Public ValidateRange As Range

Sub ValidateNumberofRows()


Set ValidateRange = Sheets("DataDump").Range("A2", Sheets("DataDump").Range("A2").End(xlDown))
TemplatePage = Application.RoundUp((ValidateRange.Rows.Count / 18), 0)


Call copy


End Sub

The idea behind this was so I can use the page numbers to concatenate it in a loop for the destination.
My sheets are named "Template1", "Template2" and so on.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top