VBA IF statement for command button?

smods

Board Regular
Joined
Feb 18, 2008
Messages
79
Office Version
  1. 365
Platform
  1. Windows
I need some code to say if A1 = Sunday then Print all sheets

else just print sheet 1, sheet 2, sheet 3, sheet 4

Cheers

Chris
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Gosh darn, my edit time ran out when I tried to make it better. Anyway.

See this thread:
http://www.mrexcel.com/forum/showthread.php?t=379378

Rich (BB code):
If ActiveSheet.[A1].Value = "Sunday" Then
Use examples from other thread
Else
ThisWorkbook.Worksheets("Sheet1").printout
 ThisWorkbook.Worksheets("Sheet2").printout
ThisWorkbook.Worksheets("Sheet3").printout
ThisWorkbook.Worksheets("Sheet4").printout
End If
Caveat emptor, you should look into defining parameters for the PrintOut, depending on how much and how you want it printed.
 
Upvote 0
Thanks but I need to specify which sheets to print.

It's either going to be all sheets if it's a Sunday or if not then it will be Sheet1, Sheet2, Sheet3, Sheet4 & Sheet 5

Chris

EDIT. Just seen the code you have added :) Thanks
 
Upvote 0
Did you see the second reply? That and the linked thread should have all info you need.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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