VBA Unique Names and Double Sided Printing

Spasmodic

Board Regular
Joined
Oct 22, 2013
Messages
83
Hello All,

Currently in excel 2016 for PC, I am running this print macro. Cells C55:C75 have unique names and in order to run the macro, I single click C55 (or whatever unique name that I want to print) and hit control b. This will print a unique sheet for that individual as there are some lookups tied to that name. The printer that I am using is capable of duplex or double sided printing and I was wondering how I could combine or add onto this print macro so that it prints double sided. For example, if you look at the macro I provided, the print range is A1:BK51, instead of cramming everything onto one side, I was wondering how I could have it print A1:AE51 on one side and then AG1:BK51 on the other side WHILE using the print macro, click unique name and hit contol b, to print the unique sheet double sided. Any help would be appreciated. Thanks.

Sub PrintSelectedNames()
'
' PrintSelectedNames Macro prints all selected athletes.
'


On Error GoTo ErrorHandler:


Dim cell As Object
For Each cell In Selection ' each selected item
'Dim i As Integer
'i = 1
' loop through weeks
'Do While SheetExists("Week" & i & "-" & (i + 1))
' grab value from roster
Range("A2").Value = cell.Value

' print it
Range("A1:BK51").PrintOut Copies:=1, Preview:=False

'i = i + 2
'Loop

Next cell

Exit Sub

ErrorHandler:
MsgBox "Something wrong happened:" & Err.Description
End Sub


Function SheetExists(SheetName As String) As Boolean
' returns TRUE if the sheet exists in the active workbook
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets(SheetName).Name) > 0 Then
SheetExists = True
Exit Function
End If
NoSuchSheet:
End Function
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The duplex option is a property of the printer and Excel does not provide syntax for VBA regarding that setting directly, but I'd say you can try to insert a page break and see how it fairs:
Code:
ActiveSheet.ResetAllPageBreaks
ActiveSheet.VPageBreaks.Add Before:=Range("AF1:AF51")
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,645
Members
449,325
Latest member
Hardey6ix

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