Clear Contents

Bryanlim

New Member
Joined
Jul 5, 2020
Messages
6
Office Version
  1. 2010
Platform
  1. Windows
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..


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
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top