print loop macro with a twist(?)

wrb

New Member
Joined
May 19, 2004
Messages
1
I have tried, unsuccessfully, to create a print loop macro for a project despite the fact that it seems fairly straight forward.

I have a print template sheet whose data is derived by a vlookup from a 4 digit code. The problem is I have 500+ codes. I need a macro that can print the template page from a list of codes on a separate sheet and give enough time for the template page to populate with data.

Is there anyone who's done this before?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi,

I used the code below to do something very similar to what you are requesting. It uses a worksheet named Mail Form Data to populate 2 worksheets that act as form letters. The Mail Form Data tab has several columns of information, ie name, street address, ect, with a control number in column A. For each control number it finds in column A, it takes that value transfers it to a variable then activates the primary form letter page, inserts that value into a cell that is used by all the vlookups, it then uses the calculate statement to refresh all the vlookups on both form letter pages, then prints both pages, and moves to the next control number, and repeats the value transfer and refresh prior to printing the next set of form letters.


Code:
Public Sub Mailer2(ranget As String)


Sheets("Mail_Form_Data").Select  

Range(ranget).Select                  


For Each Cell In Selection

                    LookUp = Cell.Value       
                                  
                    Worksheets("Letter").Activate
                                       
                    Range("C2").Value = LookUp
                    
                    Calculate
                    
                    'Printing the sections of the mailer "Letter" 1st
                    Sheets("Letter").Select
                    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
                    
                    'Printing the sections of the mailer "Payroll Report" 2nd
                    Sheets("Payroll Report").Select
                    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
            
        Next Cell


Sheets("Controls").Select
Range("A1").Select

End Sub

I'll be at work for another hour, so if you have any questions fire them back.

Sincerely,

Benjamin
 
Upvote 0

Forum statistics

Threads
1,216,188
Messages
6,129,397
Members
449,508
Latest member
futureskillsacademy

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