Macro to print a changing report based on lookups

Litmus

New Member
Joined
Mar 14, 2018
Messages
2
I have a different report to print for 80 individuals based on lookups - I am using a single unique identifier to change the data on the report (G1). Here is my very weak macro attempt but it only prints the for first person on the list. How do I make this loop to print the next report and so on...

For I = 1 To 5
Sheets("Data").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Select
Selection.Copy
Sheets("Report").Select
Range("G1").Select
ActiveSheet.Paste
Range("A1:D29").Select
Selection.PrintOut Copies:=1
Next

Any help would be very well received.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Although you are looping 5 times, it appears that you are not using the value of I to make any changes. Perhaps:

ActiveCell.Offset(1, 0).Select
should be
ActiveCell.Offset(I, 0).Select
 
Upvote 0
Thank you that is very helpful - works perfectly.
Perhaps I can ask you another question. The report contains grades - not all pupils do the same subjects, how do I remove rows with no grade? e.g. Art and Business
[TABLE="width: 591"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]Course[/TD]
[TD]Type[/TD]
[TD]Equivalency[/TD]
[TD]Grade[/TD]
[/TR]
[TR]
[TD]Art and Design[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Business[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Computer Science[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Dance[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Drama[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Drama[/TD]
[TD]RSL[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Engineering[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]English Language[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]English Literature[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]French[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Geography[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]History[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Maths[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Media Studies[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD]M2[/TD]
[/TR]
[TR]
[TD]PE/Sport[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD]M2[/TD]
[/TR]
[TR]
[TD]Religious Education[/TD]
[TD]GCSE[/TD]
[TD]x1 GCSE[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]Science[/TD]
[TD]GCSE[/TD]
[TD]x2 GCSEs[/TD]
[TD]3-3[/TD]
[/TR]
[TR]
[TD]Travel and Tourism[/TD]
[TD]BTEC[/TD]
[TD]x1 GCSE[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
There are multiple ways to accomplish this...
One way would be to sort the information by grade, then delete all the rows where there is no grade.

If the original order is important, create an "Original Order" column with sequential numbers. Then after the sort by grade, you could sort by Original Order to get back to the original sort order.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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