What I want to do may not be simple but I was hoping someone can help me out.
I have a "Print & Save" macro on a spreadsheet. When the user pushes the button it also checks to make sure they have completed the "inspection" section of one of the work book. That was easy to do because it is the same area each time that I have named.
![]()
Sub PrintSaveReport() Dim rng As Range Set rng = [Monthly_CI] Dim rng2 As Range Set rng2 = [MonthlyYes] Dim rng3 As Range Set rng3 = [MonthlyComment] If Application.WorksheetFunction.CountA(rng) = 0 Then _ Response = MsgBox("You have not completed the Monthly Cyclone Inspection." & Chr(13) & "Please go back and complete the inspection before printing", vbExclamation + vbOKOnly, "Please Read!") If Response = vbOK Then Exit Sub If Application.WorksheetFunction.CountA(rng2) And Application.WorksheetFunction.CountA(rng3) = 0 Then _ Response = MsgBox("You have indicated a 'Yes' on the Monthly Cyclone Inspection but have not included details containing corrective actions." & Chr(13) & "Please go back and complete the inspection before printing", vbExclamation + vbOKOnly, "Please Read!") If Response = vbOK Then Exit SubI have now been asked to see if I can achieve the same thing on the data entry page.![]()
'---Clear Monthly Cyclone Inspection Sheets("CTS_PinChipHoursOperated").Range("C42:C44").ClearContents Sheets("CTS_PinChipHoursOperated").Range("E42:E44").ClearContents End Sub
Column A - Dates (there will be no missed days)
Column B - has other data below but it also houses the "Period Start and End" dates. I have another sheets looking at this piece of data to do an index-match to fill in the reports.
Column H through M - Houses the required information. Now, if one is left blank that is okay, what I need to do is if all 5 are blank for the print macro to stop and prompt the user to go back and fill in the missing data.
So, I guess I need to do some type of find by row and search for all cells for the particular day in the date range and 5 one day which has all 5 cell blank....
Here is the rest of my big mess of code...maybe someone can even clean it up for me
![]()
Sub PrintSaveReport() Dim strFilename1 As String Dim strFilename2 As String Dim strFilename3 As String Dim rngRange As Range Dim Response As VbMsgBoxResult Dim rng As Range Set rng = [Monthly_CI] Dim rng2 As Range Set rng2 = [MonthlyYes] Dim rng3 As Range Set rng3 = [MonthlyComment] Dim wb As Workbook Dim wsOrder As Worksheet Dim wsCTS As Worksheet Dim wsPDL As Worksheet Dim wsPCDPC As Worksheet Set wb = ThisWorkbook Set wsOrder = wb.Sheets("RAWData") Set wsCTS = wb.Sheets("CTS_PinChipHoursOperated") Set wsPDL = wb.Sheets("PressureDropLog") Set wsPCDPC = wb.Sheets("PinChipDPChecks") '---confirm this action--- Response = MsgBox("This action will print and save a PDF of the data selected in the date range?" & Chr(13) & "Are you sure you want to continue?", vbExclamation + vbYesNo, "Please Read!") If Response = vbNo Then Exit Sub '---Check for blanks--- If Application.WorksheetFunction.CountA(rng) = 0 Then _ Response = MsgBox("You have not completed the Monthly Cyclone Inspection." & Chr(13) & "Please go back and complete the inspection before printing", vbExclamation + vbOKOnly, "Please Read!") If Response = vbOK Then Exit Sub If Application.WorksheetFunction.CountA(rng2) And Application.WorksheetFunction.CountA(rng3) = 0 Then _ Response = MsgBox("You have indicated a 'Yes' on the Monthly Cyclone Inspection but have not included details containing corrective actions." & Chr(13) & "Please go back and complete the inspection before printing", vbExclamation + vbOKOnly, "Please Read!") If Response = vbOK Then Exit Sub '---Used to get the date which is used in the file name when saved --- dtmDate = wsOrder.Range("ReportDateS").Value '---Print pages based upon preset PrintArea--- wsCTS.PrintOut wsPDL.PrintOut wsPCDPC.PrintOut '---save selcted range--- '---Create File name with dateStamp as well as the range selected above--- strFilename1 = Format(dtmDate, "yyyy") & " CTS_PinChipHoursOperated " & Format(dtmDate, "mmmyy") Sheets(Array("CTS_PinChipHoursOperated")).Select Sheets("CTS_PinChipHoursOperated").Activate ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "G:\Environmental Logs\Pin Chip DP Logs\CTS_PinChipHoursOperated_export\" & strFilename1 & ".pdf" _ , Quality:=xlQualityStandard, IncludeDocProperties:=True '--Save2 strFilename2 = Format(dtmDate, "yyyy") & " PressureDropLog " & Format(dtmDate, "mmmyy") Sheets(Array("PressureDropLog")).Select Sheets("PressureDropLog").Activate ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "G:\Environmental Logs\Pin Chip DP Logs\PressureDropLog_export\" & strFilename2 & ".pdf" _ , Quality:=xlQualityStandard, IncludeDocProperties:=True '--Save3 strFilename3 = Format(dtmDate, "yyyy") & " PinChipDPChecks " & Format(dtmDate, "mmmyy") Sheets(Array("PinChipDPChecks")).Select Sheets("PinChipDPChecks").Activate ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "G:\Environmental Logs\Pin Chip DP Logs\PinChipDPChecks_export\" & strFilename3 & ".pdf" _ , Quality:=xlQualityStandard, IncludeDocProperties:=True '---Clear Monthly Cyclone Inspection 'Sheets("CTS_PinChipHoursOperated").Unprotect Sheets("CTS_PinChipHoursOperated").Range("C42:C44").ClearContents Sheets("CTS_PinChipHoursOperated").Range("E42:E44").ClearContents 'Sheets("CTS_PinChipHoursOperated").Protect End Sub











LinkBack URL
About LinkBacks

Register To Reply
Bookmarks