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.
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: