ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro within Macro (https://www.excelbanter.com/excel-discussion-misc-queries/47480-macro-within-macro.html)

John

Macro within Macro
 
I got help from a user the other day that helped me create a macro that will
ask you what worksheet to print. Now i was wondering if i could go a step
further. Instead of typing in the worksheet you want to print (See Below) I
want to know if it can come up with a list and you can choose which one to
print. Below is a portion of the current macro that i have.

Title = "PRINT SCREEN QUESTION"
Config = vbOKCancel + vbQuestion
Ans = MsgBox(msg, Config, Title)
If Ans = vbOK Then
If Ans = vbCancel Then Exit Sub
Dim PReport As Variant
PReport = InputBox("Enter an Account Number (1-4) for the Data Input
sheet to Print", "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print3
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and Integer" & Chr(10) & "Between 1 and 4"
End Select

Bob Phillips

You might want to try the technique in this previous posting
http://tinyurl.com/cpg3m

Just change
ActiveWorkbook.Worksheets(cb.Caption).Select

to
ActiveWorkbook.Worksheets(cb.Caption).Print

to print them

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John" wrote in message
...
I got help from a user the other day that helped me create a macro that

will
ask you what worksheet to print. Now i was wondering if i could go a step
further. Instead of typing in the worksheet you want to print (See Below)

I
want to know if it can come up with a list and you can choose which one to
print. Below is a portion of the current macro that i have.

Title = "PRINT SCREEN QUESTION"
Config = vbOKCancel + vbQuestion
Ans = MsgBox(msg, Config, Title)
If Ans = vbOK Then
If Ans = vbCancel Then Exit Sub
Dim PReport As Variant
PReport = InputBox("Enter an Account Number (1-4) for the Data Input
sheet to Print", "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print3
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and Integer" & Chr(10) & "Between 1 and 4"
End Select




John

Bob

I guess i dont see where i would change what you suggested. You said change
ActiveWorkbook.activeworksheets(cb.Caption).Select
To
Activeworkbook.activeworksheets(cb.Caption).Print

Where would i put that in my formula?


"Bob Phillips" wrote:

You might want to try the technique in this previous posting
http://tinyurl.com/cpg3m

Just change
ActiveWorkbook.Worksheets(cb.Caption).Select

to
ActiveWorkbook.Worksheets(cb.Caption).Print

to print them

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John" wrote in message
...
I got help from a user the other day that helped me create a macro that

will
ask you what worksheet to print. Now i was wondering if i could go a step
further. Instead of typing in the worksheet you want to print (See Below)

I
want to know if it can come up with a list and you can choose which one to
print. Below is a portion of the current macro that i have.

Title = "PRINT SCREEN QUESTION"
Config = vbOKCancel + vbQuestion
Ans = MsgBox(msg, Config, Title)
If Ans = vbOK Then
If Ans = vbCancel Then Exit Sub
Dim PReport As Variant
PReport = InputBox("Enter an Account Number (1-4) for the Data Input
sheet to Print", "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print3
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and Integer" & Chr(10) & "Between 1 and 4"
End Select






All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com