trying to clear one shape(macro button) from sheet and it is also deleting a picture I want to keep - macro section highlighted below
...
Sub CREATENEWINVOICE()
Dim INVNO As Long
Dim CUSTNAME As String
Dim AMT As Currency
Dim DT_ISSUE As Date
Dim TERM As Byte
Dim PATH As String
Dim FNAME As String
Dim NEXTREC As Range
INVNO = Range("M1")
CUSTNAME = Range("B8")
AMT = Range("M28")
DT_ISSUE = Range("L2")
TERM = Range("L4")
PATH = "C:\Users\User\Desktop\WORKORDERS\"
'C\Users\User\Desktop\Share\WORKORDERS\
FNAME = INVNO & " - " & CUSTNAME
'COPY IN THE WORKORDER SHEET TO A NEW WORKBOOK
Sheet1.Copy
'THEN DELETE ALL THE BUTTONS ON THE WORKSHEET - I have another shape/picture I want to keep but macro is delete the button and the picture
Dim SHP As Shape
For Each SHP In ActiveSheet.Shapes
SHP.Delete
Next SHP
'the picture is not in the cell range listed below
Range("B8").Validation.Delete
If Sheet1.Range("B8") = "" Then
Range("B7:E7,B9:E14").ClearContents
End If
'SAVE THE WORKBOOK TO A SPECIFIED FOLDER
With ActiveWorkbook
.Sheets(1).Name = "WORKORDERS"
.SaveAs Filename:=PATH & FNAME, FileFormat:=51
.Close
End With
'NEED TO PUT THE DETAILS OF THE WORKORDER IN THE RECORD OF WORKORDER SHEET
Set NEXTREC = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)
NEXTREC = INVNO
NEXTREC.Offset(0, 1) = CUSTNAME
NEXTREC.Offset(0, 2) = AMT
NEXTREC.Offset(0, 3) = DT_ISSUE
NEXTREC.Offset(0, 4) = DT_ISSUE + TERM
Sheet3.Hyperlinks.Add ANCHOR:=NEXTREC.Offset(0, 7), Address:=PATH & FNAME & ".XLSX"
Dim WRKORDNO As Long
WRKORDNO = Range("M1")
Range("M1:N1,B8:E8,A18:L27,A31:F33,G31:N33").ClearContents
MsgBox "YOUR NEXT INVOICE NUMBER IS " & WRKORDNO + 1
Range("M1") = WRKORDNO + 1
Range("B8").Select
ThisWorkbook.Save
End Sub
...
Sub CREATENEWINVOICE()
Dim INVNO As Long
Dim CUSTNAME As String
Dim AMT As Currency
Dim DT_ISSUE As Date
Dim TERM As Byte
Dim PATH As String
Dim FNAME As String
Dim NEXTREC As Range
INVNO = Range("M1")
CUSTNAME = Range("B8")
AMT = Range("M28")
DT_ISSUE = Range("L2")
TERM = Range("L4")
PATH = "C:\Users\User\Desktop\WORKORDERS\"
'C\Users\User\Desktop\Share\WORKORDERS\
FNAME = INVNO & " - " & CUSTNAME
'COPY IN THE WORKORDER SHEET TO A NEW WORKBOOK
Sheet1.Copy
'THEN DELETE ALL THE BUTTONS ON THE WORKSHEET - I have another shape/picture I want to keep but macro is delete the button and the picture
Dim SHP As Shape
For Each SHP In ActiveSheet.Shapes
SHP.Delete
Next SHP
'the picture is not in the cell range listed below
Range("B8").Validation.Delete
If Sheet1.Range("B8") = "" Then
Range("B7:E7,B9:E14").ClearContents
End If
'SAVE THE WORKBOOK TO A SPECIFIED FOLDER
With ActiveWorkbook
.Sheets(1).Name = "WORKORDERS"
.SaveAs Filename:=PATH & FNAME, FileFormat:=51
.Close
End With
'NEED TO PUT THE DETAILS OF THE WORKORDER IN THE RECORD OF WORKORDER SHEET
Set NEXTREC = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)
NEXTREC = INVNO
NEXTREC.Offset(0, 1) = CUSTNAME
NEXTREC.Offset(0, 2) = AMT
NEXTREC.Offset(0, 3) = DT_ISSUE
NEXTREC.Offset(0, 4) = DT_ISSUE + TERM
Sheet3.Hyperlinks.Add ANCHOR:=NEXTREC.Offset(0, 7), Address:=PATH & FNAME & ".XLSX"
Dim WRKORDNO As Long
WRKORDNO = Range("M1")
Range("M1:N1,B8:E8,A18:L27,A31:F33,G31:N33").ClearContents
MsgBox "YOUR NEXT INVOICE NUMBER IS " & WRKORDNO + 1
Range("M1") = WRKORDNO + 1
Range("B8").Select
ThisWorkbook.Save
End Sub