Print if

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
I have a macro button that allows user to print a couple of different sheets. I am wanting to update if it is possible. What I am looking for is if the word "Voids" is present on the main sheet (called "Data Sheet") then to print the Sheet named "Porosity". The code I have posted below is what I am currently using and it works great.

I would like to put that portion of the code at the end if its possible.



Code:
Sub printdatasheet()
Application.ScreenUpdating = False
'Add temp test test
Sheets("Test Sheet").Columns("w:w").Copy
Sheets("Data Sheet").Range("ProductInfo").Insert Shift:=xlToRight
 
Application.GoTo Reference:=Worksheets("Data Sheet").Range("C2")
'select the range between the two notes range, merge and
'center and then add "Quality Control Data Sheet" into the Range
 
Sheets("Data Sheet").Range(Range("Notes1").Offset(, 1), Range("FTIRDesc").Offset(, -1)).Select
 
Application.ScreenUpdating = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = True
.ReadingOrder = xlContext
.MergeCells = True
End With
With Selection.Font
.Name = "Monotype Corsiva"
.FontStyle = "Regular"
.Size = 22
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("H2:K2").Select
ActiveCell.FormulaR1C1 = "Quality Control Data Sheet"
 
 
'Print MDF and Data Sheet
Dim X As Integer
Dim Y As Integer
START:
On Error GoTo ERROR1
X = InputBox("HOW MANY COPIES OF THE DATA SHEET WOULD YOU LIKE?", "COPIES?")
Y = InputBox("HOW MANY COPIES OF THE MDF SHEET WOULD YOU LIKE?", "COPIES?")
 
If X = 0 Then
GoTo PRINTMDF
Else
'print Data
Sheets("Data Sheet").PrintOut Copies:=X, Collate:=True
Range("D5").Select ''''???
 
Cells.find(what:="TEMP", After:=ActiveCell, LookIn:=xlValues, lookat:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.EntireColumn.Delete
 
End If
'Print MDF
PRINTMDF:
If Y = 0 Then
Exit Sub
Else
Sheets("MDF").PrintOut Copies:=Y
End If
'Cells.find(What:="TEMP", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
' xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
' , SearchFormat:=False).Activate
' Selection.EntireColumn.Delete
Exit Sub
ERROR1:
MsgBox ("Please enter only numeric values")
GoTo START:
 
 
 
End Sub
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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