Code to print 1st page of multiple sheets

Status
Not open for further replies.

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
Hi,

I'd like to add the necessary code to a CommandButton (called CommandButton_Choose_These_Students) that does the following five (5) things ...

1. Creates a new worksheet (which is to be a copy of a worksheet called ... Student Profile Template) for each ID number found in the range ... PrintTemplate!AH49:AH400 .... most likely, out of all those cells, there might only be a handful that actually have a student ID in them,
sometimes perhaps 60 or so, but I have to cover the possibility of more.

2. Each of the new sheets created should be named the ID Number that was found in the range mentioned above .... so, if there were just three ID numbers found in that range (the ID numbers being ... 32765, 34985, 23660), then three new sheets should be created and named 32765, 34985, and 23660.

3. Print just Page 1 (Range A1:Y39) of each of those new Sheets made.

4. Delete those very same sheets, once the printing has been done. There will be other sheets that exist in the workbook that I do not want deleted, so just delete the sheets that were created in step 1

5. Clear the contents of the following four ranges ...

* PrintTemplate!W49:W400
* PrintTemplate!Z49:Z400
* PrintTemplate!AC49:AC400
* PrintTemplate!AC49:AC400

Out of interest, is there a way to code it so each is printed as a PDF ? If not, absolutely not a problem ... just interested.

Any help with the coding of this would be hugely appreciated.

Very kindest regards,

Chris
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Duplicate: Code to create temporary Sheets, Print them, the Delete the Sheets

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule #12 here: Forum Rules).

Not quite sure why you re-posted it, especially since you received a reply on that thread that you never responded to...
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,043
Messages
6,176,046
Members
452,701
Latest member
rfhandel

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