ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Question (https://www.excelbanter.com/excel-discussion-misc-queries/47120-vba-question.html)

John

VBA Question
 
I have a little problem. I need to write a VBA. I have a button that will
print four letters that are located in a seperate worksheet. Currently I
have a macro that goes to that worksheet and prints all four. But I want to
have a pop-up that will ask Which letter they want to print. I believe that
this is possible, but i need some help developing it. Any help would be
appreciated.

Thank you


Rowan

One way would be to record 4 different macros - one to print each
letter, in my example I have called them Print1, Print2, etc. Then
attach the macro below to your print button:

Sub Pintit()
Dim PReport As Variant
PReport = InputBox("Enter 1 to 4 for report to print" _
, "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print2
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and integer" & Chr(10) _
& "between 1 and 4"
End Select
End Sub

Hope this helps
Rowan

John wrote:
I have a little problem. I need to write a VBA. I have a button that will
print four letters that are located in a seperate worksheet. Currently I
have a macro that goes to that worksheet and prints all four. But I want to
have a pop-up that will ask Which letter they want to print. I believe that
this is possible, but i need some help developing it. Any help would be
appreciated.

Thank you


John

Rowan

Thank you very much. It worked Perfectly. Thank very much for you help


"Rowan" wrote:

One way would be to record 4 different macros - one to print each
letter, in my example I have called them Print1, Print2, etc. Then
attach the macro below to your print button:

Sub Pintit()
Dim PReport As Variant
PReport = InputBox("Enter 1 to 4 for report to print" _
, "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print2
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and integer" & Chr(10) _
& "between 1 and 4"
End Select
End Sub

Hope this helps
Rowan

John wrote:
I have a little problem. I need to write a VBA. I have a button that will
print four letters that are located in a seperate worksheet. Currently I
have a macro that goes to that worksheet and prints all four. But I want to
have a pop-up that will ask Which letter they want to print. I believe that
this is possible, but i need some help developing it. Any help would be
appreciated.

Thank you



Rowan

You're welcome.

"John" wrote:

Rowan

Thank you very much. It worked Perfectly. Thank very much for you help


"Rowan" wrote:

One way would be to record 4 different macros - one to print each
letter, in my example I have called them Print1, Print2, etc. Then
attach the macro below to your print button:

Sub Pintit()
Dim PReport As Variant
PReport = InputBox("Enter 1 to 4 for report to print" _
, "Print Report", 1)
Select Case PReport
Case 1
Call Print1
Case 2
Call Print2
Case 3
Call Print2
Case 4
Call Print4
Case ""
MsgBox "User Cancelled"
Case Else
MsgBox "You must enter and integer" & Chr(10) _
& "between 1 and 4"
End Select
End Sub

Hope this helps
Rowan

John wrote:
I have a little problem. I need to write a VBA. I have a button that will
print four letters that are located in a seperate worksheet. Currently I
have a macro that goes to that worksheet and prints all four. But I want to
have a pop-up that will ask Which letter they want to print. I believe that
this is possible, but i need some help developing it. Any help would be
appreciated.

Thank you




All times are GMT +1. The time now is 01:18 AM.

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