VbA code to print specific worksheets based on value of a worksheet

amxtomzo

Active Member
Joined
Nov 7, 2009
Messages
312
I am prepareing to create a new spreadsheet and one of my thoughts that I want to be able to do is, I want to put into a command button printing only specific worksheets in a workbook only if on that sheet cell A1 has a value.

for example if evrything works out right, i may only want to print out sheets 1,2,3,4 & 5 only because cell A1 will have a value, it will be text if it does. I do not want to print out sheets 6, 7, 8, 9 & 10 because cell A1 has no value at all.

So there is a range of 10 Worksheets, but only a few could have information on them and those would the sheets I want to print out

the referenceing cell will be exactly the same on all worksheets.

Can this be done????
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Are you saying that each sheet has a value in A1 then print that sheet if so then try this code

Sub printout1()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Range("A1") <> "" Then
ws.PrintOut
End If
Next ws
End Sub
 
Upvote 0
Pleased to read you have a working solution Thomas.;)
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,763
Members
452,940
Latest member
rootytrip

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