Slight Variation to selctive printing

Montana34

New Member
Joined
Sep 13, 2007
Messages
25
I have a userform that has mulitple buttons and each button prints specific worksheets. I have one button that I want to print specific worksheets, but only those that have A1 filled in. The kicker is that I always want to print sheet 4 but sheets 1-3 only want the one that has data in A1.

Your help is greatly needed. Thank you
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

this is my interpretation of your question
Code:
Sub test()
Dim i As Long
 
    For i = 1 To 3
    If Len(Sheets(i).Range("A1")) > 0 Then Sheets(i).PrintOut
    Next i
    
    Sheets(4).PrintOut
End Sub

kind regards,
Erik
 
Upvote 0
very cool thank you, I have another spin to it now. I have those same sheets inside my workbook. This time I want to email just the sheets that have something in cell A1.

thank you again
 
Upvote 0
I started to answer because I know how to print and to loop
now this is a different question ... it's one that I usually skip
so just throwing some ideas, not in particular order

you can record a macro while doing your operations
did you check the VBA helpfiles? if I remember well that part is easy to understand
did you search on the board?

also
http://office.webforums.nl/forum/viewtopic.php?t=25952
I think
www.glynnconsulting.co.uk
a search for "Ron De Bruin" will be really useful
http://www.rondebruin.nl/sendmail.htm#Introduction

email a sheet, let's see what I have in my library

Code:
Sub AttachWorksheetToMail()
    Dim x As Boolean
    ActiveSheet.Copy
    x = Application.Dialogs(xlDialogSendMail).Show
End Sub
that's all I have
 
Upvote 0
Hi,

this is my interpretation of your question
Code:
Sub test()
Dim i As Long
 
    For i = 1 To 3
    If Len(Sheets(i).Range("A1")) > 0 Then Sheets(i).PrintOut
    Next i
    
  End Sub

kind regards,
Erik

Can i use this code to do the same thing except instead of .PrintOut i want to copy the sheet to another workbook.


Thank you again in advance for you help.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

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