Checking the Code

PMRetired2012

Board Regular
Joined
Aug 6, 2019
Messages
123
What im wondering is there a way to shorten the code for these lines of code that i have written and get the same outcome. What i want to do is only print pages that have something in cell A3 and S3 and then i want it to print both pages. Here is the code i have writen>

If OptionButton2 = True Then

Dim A As Integer
A = 1
For A = 1 To 12
Sheets(A).Select
If WorksheetFunction.CountA(ActiveSheet.Range("A3:A54")) <> 0 Then
Range("A1:R54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
'Print
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
A = A + 1
End If
Next A



If CheckBox1.Value = True Then

Dim B As Integer
B = 1
For B = 1 To 12
Sheets(B).Select
If WorksheetFunction.CountA(ActiveSheet.Range("S3:S54")) <> 0 Then
Range("S1:AL54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
'Print
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
B = B + 1
End If
Next B
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
.
VBA Code:
Option Explicit

Sub PrintComplete()
    
    Dim ws As Worksheet
    
    'check if cell is empty.
    For Each ws In ActiveWorkbook.Worksheets
        
        If ws.Cells(3, 1) = "" Or ws.Cells(3, 19) = "" Then
        
        Else
            ws.PrintOut
        End If
        
    Next

End Sub
 
Upvote 0
i failed to tell you that i have choices in a userform that i can select and i dont think this code you gave me will work. im going to put a pic on here of my userform that has the choices i can choose from to print. That is why i dont think the code you gave me will work. Let me know what you decide. Thanks



View attachment 24441

.
 
Upvote 0
The pic attach doesn't work.

The best method would be to place your workbook on a download site for review. That way your actual working environment and the code is presented. Do not include any
confidential information in the workbook.
 
Upvote 0
One site is DROPBOX.COM. There are other sites out there as well. They are free and easy to use. Google.

Once you place the workbook on the site, it will provide you with a means to copy the URL location of the workbook. Copy
that URL and paste it here using the LINK selection in the menu above.
 
Upvote 0
Im Sorry but you need to give me step by step instruction i dont know how to use dropbox. give me some other ways.
thanks
 
Upvote 0
Go to : Dropbox

Create an account.

Log in to your account and save your workbook as a file in your account.

Somewhere on the Dropbox menu will be a selection for copying the file location (URL) on Dropbox.

Copy that URL and paste it in a reply here.

You were able to create an account here on MREXCEL.COM and post a question. There is no reason you can't navigate Dropbox.
 
Upvote 0

Forum statistics

Threads
1,215,324
Messages
6,124,249
Members
449,149
Latest member
mwdbActuary

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