ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Evening,
I am using the code shown below which works fine, just need an edit to catch an error.
In cell A3 will be a value like so.04 APRIL 05 MAY 06 JUNE etc etc
When i run my code i need to make sure that the value in cell A3 is valid from a list BEFORE the save continues,thus show me a MsgBox to say otherwise.
Example.
IF the value is 06 JUNE then the code will run & the save will take place.
BUT
If the value is say 01 MARCH then a MsgBox will be shown & the code doesnt run anymore.
Im not sure how i write my list of what is allowed,
Something like,
I am using the code shown below which works fine, just need an edit to catch an error.
In cell A3 will be a value like so.04 APRIL 05 MAY 06 JUNE etc etc
When i run my code i need to make sure that the value in cell A3 is valid from a list BEFORE the save continues,thus show me a MsgBox to say otherwise.
Example.
IF the value is 06 JUNE then the code will run & the save will take place.
BUT
If the value is say 01 MARCH then a MsgBox will be shown & the code doesnt run anymore.
Im not sure how i write my list of what is allowed,
Something like,
Rich (BB code):
If Range("A3").Value = 04 APRIL, 05 MAY, 06 JUNE Then
Code will contine.
Else
MsgBox "INVALID MONTH"
Exit sub
Rich (BB code):
Private Sub INCOMETRANSFER()
Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\INCOME\" & _
Range("A3") & " " & Range("D3") & " " & Range("E3") & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "GRASS CUTTING INCOME SHEET " & Range("A3") & " " & Range("D3") & " WAS NOT SAVED AS IT ALREADY EXISTS", vbCritical + vbOKOnly, "INCOME SUMMARY GRASS SHEET FAILED MESSAGE"
PDFExists = True
Exit Sub
Else
PDFExists = False
End If
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True
MsgBox "GRASS CUTTING INCOME SHEET " & Range("A3") & " " & Range("D3") & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "INCOME SUMMARY GRASS SHEET SUCCESSFULL MESSAGE"
Range("A5:A30").NumberFormat = "@"
End With
End Sub