Create Spreadsheet Macro to Auto group select tabs to print multiple sheets at the click of a button

Hey Friends!
Here’s what I am trying to do and for the life of me I just can’t figure it out.

I am trying to write a Macro to attach to a button so that when I click the button, the macro will group select a number of specified tabs a in the workbook in order to be able to print those selected “active” tabs as a single print.

I know I can manually hold ctrl + click on the tabs I want to print but I would love to have it automatically select the correct tabs for the specific report pages that I want.

Does anyone know how to do this?
I would be really grateful.

Thank you in advance for you help.

Cheers!
Jordan.

1 Like

Hello @JordanGosling

If I understand correctly, you mean sheets when saying tabs. Unfortunately, there is no method that would allow selecting a sheet as it done with CTRL + Left-click via editor interface.

If you know how this can be with VBA, then you can share a sample macro so that we will consider registering an enhancement.

Terribly sorry for the Late reply.
Please see below the my working and current EXCEL VBA code (Assume Called Function and Variable) assume comments begin with ’

My Excel VBA Code selects sheets by name and then exports them as a save file.

I am showing the extra export code below to show context but at the moment I would like the OnlyOffice Macro to select the Defined Pages (either from a predefined array OR calling by Sheet name). That said, if the same functions could be created, that would be great haha.

'Sample Code
'Variables previously defined
'Select sheets for saving to PDF

Sheets(Array(“Client Engagement”, “Agent Disclosure”, “Client Note Template”, “Step 1 Obtain Goals”, “Step 2 Gather Information”, “Step 3 Coverage Amt & Type”, “PERM Suitability”, “PERM Suitability Spouse”)).Select

'Export Selected Sheets to PDF

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FolderPathforSV & "" & AgentName & " - InfoGather for " & FirstName & " " & LastName & " " & Format(CreationDate, “MMM DD YYYY”)

1 Like

how to save as pdf using macro alone

@JordanGosling, as I can see that provided code does not use Sheets.PrintOut method, it exports spreadsheet as PDF which is technically different operation from original request. Please clarify your exact goal.

As for the way to select several sheets: I’ll check the availability of such method or any ways to achieve that.


Hello @sajeer

Please create new topic for this question as it differs from original request on printing out. I’d be much better to run discussion separately to avoid mixing up topics.