zombiemaster
Board Regular
- Joined
- Oct 27, 2009
- Messages
- 245
Hoping someone has some thoughts to share to speed up this macro.
Basically, the user selects a cell and clicks the macro button. The macro copes details from that row and populate a 'work item' on a hidden tab, then unhides that tab, prints it to the default printer (usually PDF) then hides the tab again.
Right now, the code below takes 30 seconds to run and open the print dialog box. That will work if needed but we have a team of 15 people who are going to be using this daily and I am hoping to speed it up before I have to present this to management for approval - 30 seconds multiplied by 75-100 times each day adds up quickly and management is all about speed and efficiency...
Anything you can think of is appreciated!
Thanks for any insights!
~ZM~
Basically, the user selects a cell and clicks the macro button. The macro copes details from that row and populate a 'work item' on a hidden tab, then unhides that tab, prints it to the default printer (usually PDF) then hides the tab again.
Right now, the code below takes 30 seconds to run and open the print dialog box. That will work if needed but we have a team of 15 people who are going to be using this daily and I am hoping to speed it up before I have to present this to management for approval - 30 seconds multiplied by 75-100 times each day adds up quickly and management is all about speed and efficiency...
Anything you can think of is appreciated!
VBA Code:
Sub create_work_item()
'
' create_work_item Macro
' this macro takes the data from whichever row is selected in the tracking sheet and
' converts it into a standard work item using the template in the hidden tab and prints to your
' default printer (PDF)
' moves to the first cell in the selected row
ActiveSheet.Cells(ActiveCell.Row, 1).Select
' check to see if the row is valid
If ActiveCell = "" Then
MsgBox "You may have chosen a blank row by mistake, as this row does not have a Date Received." & vbCrLf & _
" " & vbCrLf & _
"Please check with Support for assistance or choose a different policy and try again."
Else
' copy that cell and paste into the work item sheet
Selection.Copy
Sheets("MACRO TESTING").Range("B2").PasteSpecial Paste:=xlPasteValues
' move to each cell in order and paste into the corresponding cells in the work item template
ActiveCell.Offset(0, 2).Copy 'rep initials who is pulling the item
Sheets("MACRO TESTING").Range("B30").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 3).Copy 'last name
Sheets("MACRO TESTING").Range("B8").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 4).Copy 'first name
Sheets("MACRO TESTING").Range("B7").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 5).Copy 'policy #
Sheets("MACRO TESTING").Range("B9").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 7).Copy 'RUSH
Sheets("MACRO TESTING").Range("B4").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 8).Copy 'item type
Sheets("MACRO TESTING").Range("B19").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 10).Copy 'comments
Sheets("MACRO TESTING").Range("B21").PasteSpecial
ActiveCell.Offset(0, 11).Copy 'CC Rep
Sheets("MACRO TESTING").Range("B3").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 12).Copy 'caller name
Sheets("MACRO TESTING").Range("B13").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 13).Copy 'caller type
Sheets("MACRO TESTING").Range("B14").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 14).Copy 'tel #
Sheets("MACRO TESTING").Range("B15").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 15).Copy 'fax #
Sheets("MACRO TESTING").Range("B16").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 16).Copy 'email
Sheets("MACRO TESTING").Range("B17").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 17).Copy 'reminder
Sheets("MACRO TESTING").Range("B28").PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, 18).Copy 'SSN
Sheets("MACRO TESTING").Range("B10").PasteSpecial Paste:=xlPasteValues
ActiveSheet.Cells(ActiveCell.Row, 1).Select
' print the work item
Application.ScreenUpdating = False
With Sheets("MACRO TESTING")
.Visible = True
.PrintOut Copies:=1, Collate:=True
.Visible = False
End With
' clear out the work item for the next use
Sheets("MACRO TESTING").Range("B2:B37").ClearContents
Application.ScreenUpdating = True
MsgBox "Your work item has been successfully printed."
End If
End Sub
Thanks for any insights!
~ZM~