Variable Macro

R

Ronbo

I am trying to create a way to automatically print
reports as ordered. I have a worksheet with numerous
reports and a client may want various reports and in
various quantities. I have a list of what they want i.e.
2ea. - reportA: 5ea. - reportC, etc. I have macros to
print each report such as
macro "PrnReportA" , "PrnReportC", ect. What I want is
to find a way to run 2-reportA:'s and 5-reportC's
automatically.. Next time the request will be different
and the process needs to change to what is then
requested. So it would be something

Any suggestions will be appreciated.
 
R

Ronbo

-----Original Message-----

This will print X number of reports of whichever type you need.

Sub PrintMaster(Report as String, Number as integer)
Dim i as integer
For i = 1 to Number Step 1
Select Case Report
Case "A": PrnReportA
Case "B": PrnReportB
Case "C": PrnReportC
'add more cases for more reports
End Select
Next i
End Sub

For your example (2 of A and 5 of C), you would have to
call PrintMaster twice. Not sure how you are getting the
input from the user. If you post more info about how
you are getting the input, I might be able to come up
with the rest of what you need.

Marcotte:

Thanks for your offer to help. First of all, I am
importing text data, manipulating it and reporting it.
What I am trying to do is completely automate the
procedure. It sounds to me that the process you
suggested would still have to be watched over with manual
input.

I think you understand what I am looking for, a "print
master macro" that can figure out what it needs to
print. In the following situation I want the "print
master macro" to print 2-A, 0-B, 5-C,etc using the macros
assigned to them. Again, the next request will be
different.

Report A B C D E
Copies 2 0 5 1 10
 
G

Guest

-----Original Message-----


If the requested number of reports is in the range A1:C1
on Sheet1, then this (combined with PrintMaster) will
work. Of course to *completely* automate the process you
will have to an event function (probably
Workbook_BeforeClose) call PrintRequest.
Sub PrintRequest()
Dim NumA As Integer, NumB As Integer, NumC As Integer
With Worksheets("sheet1")
NumA = .[a1]
NumB = .[b1]
NumC = .[c1] 'add NumD, NumE etc for more reports
End With
PrintMaster "A", NumA
PrintMaster "B", NumB
PrintMaster "C", NumC
End Sub
.

Thanks a lot. It looks like it can help me.
 
G

Guest

-----Original Message-----
-----Original Message-----


If the requested number of reports is in the range
A1:C1
on Sheet1, then this (combined with PrintMaster) will
work. Of course to *completely* automate the process you
will have to an event function (probably
Workbook_BeforeClose) call PrintRequest.
Sub PrintRequest()
Dim NumA As Integer, NumB As Integer, NumC As Integer
With Worksheets("sheet1")
NumA = .[a1]
NumB = .[b1]
NumC = .[c1] 'add NumD, NumE etc for more reports
End With
PrintMaster "A", NumA
PrintMaster "B", NumB
PrintMaster "C", NumC
End Sub
.

Thanks a lot. It looks like it can help me.

I have modified to

Dim NumA As Integer, NumB As Integer, NumC As Integer
With Worksheets("Input")
NumA = .[E8]
NumB = .[F8]
NumC = .[G8] 'add NumD, NumE etc for more reports
End With
Application.Run "PRN1", NumA
Application.Run "PRN2", NumB
Application.Run "PRN3", NumC
End Sub


But, it stops at application.run.

Any ideas?
 
Top