ClarityNDT
New Member
- Joined
- Mar 25, 2020
- Messages
- 12
- Office Version
- 2013
- Platform
- Windows
Good afternoon.
I'm having some issues with a script that does some checking of a sheet prior to running a save operation. I have included the entire script for reference.
The script checks the values of a set range of cells per worksheet to detect errors on a user completed form before saving and publishing as a pdf.
Firstly, apologies for my crude copy/paste building of this code
I'm having a specific issue with this section:
This file is checking to see if the proposed filename already exists, and if it does I need the user to be able to make a choice on overwriting it or cancelling the script. However currently when yes is clicked nothing happens.
I would like this to continue on with the script and check the remaining QC fields then run the save script but cannot figure out why it wont.
Any clues?
TIA
I'm having some issues with a script that does some checking of a sheet prior to running a save operation. I have included the entire script for reference.
Code:
Sub QCCheck()
Dim QC1 As String
Dim QC2 As String
Dim QC3 As String
Dim QC4 As String
Dim QC5 As String
Dim QC6 As String
Dim QC7 As String
Dim QC8 As String
Dim QC9 As String
Dim qc10 As String
Dim FileName As String
Dim path As String
Dim Cust As String
Dim pdfpath As String
'recalculate the entire sheet
ActiveSheet.Calculate
'Recalculates the QC fields to ensure they're up to date
Range("V1:V25").Calculate
'set the QC check cells
QC1 = Range("V13").Value
QC2 = Range("V14").Value
QC3 = Range("V15").Value
QC4 = Range("V16").Value
QC5 = Range("V17").Value
QC6 = Range("V18").Value
QC7 = Range("v19").Value
QC8 = Range("v20").Value
QC9 = Range("v21").Value
qc10 = Range("V22").Value
'set the variables
FileName = Range("v8").Value
path = "R:\"
Cust = Range("v11")
pdfpath = "R:\"
'Starts checking the document
If QC1 <> "0" Then
MsgBox ("Please review results sheet and complete all required fields")
Exit Sub
Else
If QC2 <> "0" Then
MsgBox ("Please select a customer.")
Exit Sub
Else
If QC3 <> "0" Then
MsgBox ("Previous revision does not exist. Please check revision status and details")
Exit Sub
Else
If QC4 <> "0" Then
MsgBox ("Please check technique revision status.")
Exit Sub
Else
If QC5 <> "0" Then
MsgBox ("Please complete revision details.")
Exit Sub
Else
If QC6 <> "0" Then
If MsgBox("File already exists. Would you like to replace the existing file?", vbYesNo) = vbNo Then
Exit Sub
Else
If QC7 <> "0" Then
MsgBox ("Please check created date in results sheet")
Exit Sub
Else
If QC8 <> "0" Then
MsgBox ("Please check report dates in results sheet")
Exit Sub
Else
If QC9 <> "0" Then
MsgBox ("Coverage is incorrect please check and try again")
Exit Sub
Else
If qc10 <> "0" Then
MsgBox ("Coverage is incorrect, please check and try again")
Exit Sub
Else
'We've checked the file for errors, now lets check that a directory exists and create it if it doesn't.
If Len(Dir(pdfpath & Cust, vbDirectory)) = 0 Then
MkDir (pdfpath & Cust)
End If
'Now call the sub routine for saving the file as excel
Call saveexcelcreatepdf
'Now give the user the option to print
'Call print_list
'time to close off all the if statements from the QC checks. Make sure there are enough!
'QC1
End If
'QC2
End If
'QC3
End If
'QC4
End If
'QC5
End If
'QC6
End If
'QC7
End If
'QC8
End If
'QC9
End If
'QC10
End If
'close off the save file loop
End If
'final refresh of the QC cells incase someone tries to click save again
Range("V1:V25").Calculate
'copy paste source data to allow easy edits on next revision
Worksheets("resultssheet").Range("T2:BH149").Copy
Worksheets("resultssheet").Range("T2:BH149").PasteSpecial xlPasteValues
'clear clipboard
Application.CutCopyMode = False
End Sub
The script checks the values of a set range of cells per worksheet to detect errors on a user completed form before saving and publishing as a pdf.
Firstly, apologies for my crude copy/paste building of this code
I'm having a specific issue with this section:
Code:
If QC6 <> "0" Then
If MsgBox("File already exists. Would you like to replace the existing file?.", vbYesNo) = vbNo Then
Exit Sub
Else
This file is checking to see if the proposed filename already exists, and if it does I need the user to be able to make a choice on overwriting it or cancelling the script. However currently when yes is clicked nothing happens.
I would like this to continue on with the script and check the remaining QC fields then run the save script but cannot figure out why it wont.
Any clues?
TIA