ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Hi,
I have an Income sheet which prints fine on a button & the code shown below.
I then copied the Income code & altered its cell reference etc so its the same but for the Expenses button & the code is shown below.
The Income code does all things correct without any issues.
The Expenses code on the other hand does all things correct BUT the sheet thats saved is the Income sheet.
I have looked through the code a few times and cant see why or where the fault is as to why Income & not the Expenses sheet ?
Do you see the issue.
Thanks
I have an Income sheet which prints fine on a button & the code shown below.
Code:
Private Sub GrassSummaryIncomeSheet_Click() Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\INCOME 2019-2020\" & Range("A3") & " " & Range("D3") & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "INCOME GRASS SHEET " & Range("A3") & " " & Range("D3") & " WAS NOT SAVED AS IT ALLREADY 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 SHEET " & Range("A3") & " " & Range("D3") & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "INCOME SUMMARY GRASS SHEET MESSAGE"
Range("A5:B30").ClearContents
Range("A5").Select
ActiveWorkbook.Save
End With
End Sub
I then copied the Income code & altered its cell reference etc so its the same but for the Expenses button & the code is shown below.
Code:
Private Sub GrassSummaryExpensesSheet_Click() Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\GRASS CUTTING\CURRENT GRASS SHEETS\EXPENSES 2019-2020\" & Range("M3") & " " & Range("P3") & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "EXPENSES GRASS SHEET " & Range("M3") & " " & Range("P3") & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly, "EXPENSES SUMMARY GRASS SHEET MESSAGE"
Exit Sub
End If
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True
MsgBox "GRASS SHEET " & Range("M3") & " " & Range("P3") & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "EXPENSES SUMMARY GRASS SHEET MESSAGE"
Range("M5:P35").ClearContents
Range("A5").Select
ActiveWorkbook.Save
End With
End Sub
The Income code does all things correct without any issues.
The Expenses code on the other hand does all things correct BUT the sheet thats saved is the Income sheet.
I have looked through the code a few times and cant see why or where the fault is as to why Income & not the Expenses sheet ?
Do you see the issue.
Thanks