ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,280
- Office Version
- 2007
- Platform
- Windows
Hi,
I am using the code supplied below.
The code works fine to a point,that point being somethings cell B3 will be empty so the line of code shown in red below then pops up an error message.
I will be removing that line of code but can you advise a line of code to replace it so that i then see (2) entered into cell B3
If all is good then my saved pdf will be as follows 2020_05 MAY (2)
I did try this but just got a 2
Thanks
I am using the code supplied below.
The code works fine to a point,that point being somethings cell B3 will be empty so the line of code shown in red below then pops up an error message.
I will be removing that line of code but can you advise a line of code to replace it so that i then see (2) entered into cell B3
If all is good then my saved pdf will be as follows 2020_05 MAY (2)
I did try this but just got a 2
VBA Code:
Range("B3").Value = (2)
Thanks
Rich (BB code):
Private Sub SecondMonthsSheet_Click()
Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\INCOME 2020-2021\" & Range("D3") & "_" & Format(Month(DateValue(Range("A3") & " 1, " & "2020")), "00") & " " & Range("A3") & " " & Range("B3") & " " & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "GRASS CUTTING INCOME SHEET " & Range("A3") & " " & Range("B3") & " " & Range("D3") & " WAS NOT SAVED AS IT ALREADY EXISTS", vbCritical + vbOKOnly, "INCOME SUMMARY GRASS SHEET MESSAGE"
Exit Sub
End If
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True
MsgBox "GRASS CUTTING INCOME SHEET " & Range("A3") & " " & Range("B3") & " " & Range("D3") & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "INCOME SUMMARY GRASS SHEET MESSAGE"
Range("A5:B30").ClearContents
Range("A5").Select
Range("B3").Value = Range("B3").Value + 1
Range("A5:A30").NumberFormat = "@"
ActiveWorkbook.Save
End With
End Sub