ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
I am using the code below.
The goal is to copy the existing worksheet, place it at the end of my other worsheets & take the name from cell G13
When i run it all works fine up until the code in Red below.
I then see this error supplied below message.
When i check the formula ACTIONLIST its actually on sheet called INFO
Do you see an issue as to why or can you advise another way to do the same task
Thanks
The goal is to copy the existing worksheet, place it at the end of my other worsheets & take the name from cell G13
When i run it all works fine up until the code in Red below.
I then see this error supplied below message.
When i check the formula ACTIONLIST its actually on sheet called INFO
Do you see an issue as to why or can you advise another way to do the same task
Thanks
Rich (BB code):
Private Sub Generate_Pdf_Click()
Dim answer As Integer
Dim sPath As String, strFileName As String
Dim wks As Worksheet
Set wks = ActiveSheet
With ActiveSheet
If Range("G13") = "" Then
MsgBox "NO NAME SELECTED IN THE CUSTOMER DETAILS SECTION", vbCritical, "NO CUSTOMER SELECTED MESSAGE"
Range("G13").Select 'CHECKING IF CUSTOMER IS SELECTED
Exit Sub
End If
If Range("L18") = "" Then
MsgBox ("PLEASE SELECT A PAYMENT TYPE "), vbCritical, "PAYMENT TYPE WAS NOT SELECTED"
Range("L18").Select 'CHECKING IF PAYMENT TYPE HAS BEEN SELECTED
Exit Sub
End If
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, fileName:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
End With 'CURRENT INVOICE IS NOW SAVED
With Sheets("DATABASE")
Worksheets("DATABASE").Activate
End With
Set rng = ActiveSheet.Columns("A:A")
findString = Worksheets("INV").Range("G13").Value
Set cell = rng.Find(What:=findString, LookIn:=xlFormulas, _
LookAt:=xlWhole, MatchCase:=False) ' CUSTOMER FOUND IN COLUMN A
If cell Is Nothing Then
MsgBox "NO CUSTOMER WAS FOUND"
Else
With Sheets("DATABASE")
cell.Select
ActiveCell.Offset(0, 15).Select ' CUSTOMERS CELL IN COLUMN P NOW SELECTED
End With
End If
If Len(ActiveCell.Value) <> 0 Then
ValueInInvoiceCell.Show 'MESSAGE SHOWN IF CUSTOMERS INVOICE CELL IN COLUMN P HAS A VALUE IN IT
Exit Sub
Else
TransferInvoiceNumber.Show 'NOW ENTER INVOICE NUMBER IN CUSTOMERS CELL IN COLUMN P & NOW HYPERLINKED
End If
With Sheets("DATABASE")
Worksheets("INV").Activate 'WORKSHEET INVOICE HAS NOW BEEN ACTIVATED
End With
With ActiveSheet
'ActiveWindow.SelectedSheets.PrintOut copies:=1
End With
' START OF COPY CODE HERE
ActiveSheet.Copy After:=Worksheets(Sheets.Count) 'NEW WORKSHEET NOW CREATED
If wks.Range("G13").Value <> "" Then
On Error Resume Next
ActiveSheet.NAME = wks.Range("G13").Value
End If
End With
' END OF COPY CODE
wks.Activate
Range("L4").Value = Range("L4").Value + 1 'INVOICE IS INCREMATED BY 1
Range("G27:L36").ClearContents 'WORKSHEET DETAILS NOW CLEARED
Range("G46:G50").ClearContents
Range("L18").ClearContents
Range("G13").ClearContents
Range("G13").Select
ActiveWorkbook.Save
Call Sheet14.PasteIfFormulas_Click
ActiveWorkbook.Save
End With
End Sub