Hello I need Help i just copy this vba from another post, it almost works already but still has last 1 problem for me , the vba is already can be autosave already in folder... but my problem is, when i save it already the contents in the next receipts its either empty or the macro file content is not cleared,
i want this vba to work as.. the original macro file of selected contents will be cleared, and the save 1 will retain the stocks i type thanks..
i want this vba to work as.. the original macro file of selected contents will be cleared, and the save 1 will retain the stocks i type thanks..
VBA Code:
Sub SaveinwithtNewname()
Application.ScreenUpdating = False
Dim NewFN As String
Dim CurrentInvoiceNumber As String
Dim NextInvoiceNumber As String
CurrentInvoiceNumber = Range("H3").Value
NextInvoiceNumber = "" & CStr(CurrentInvoiceNumber) + 1
NewFN = "C:\Users\Bryan Lim\Documents\Hapi Bongao\Hapi Incoming Stocks Invoice\Warehouse Inventory Sheet" & CurrentInvoiceNumber & ".xlsx"
Debug.Print CurrentInvoice; Number, NextInvoiceNumber
ThisWorkbook.Worksheets.Copy ' // THIS WILL COPY ALL THE SHEETS
With ActiveWorkbook
.SaveAs _
Filename:=NewFN, _
FileFormat:=xlOpenXMLWorkbook
Range("B4:C8").ClearContents
Range("A12:I46").ClearContents
.Close _
SaveChanges:=False
End With
Range("H3").Value = NextInvoiceNumber
Application.ScreenUpdating = True
End Sub