Wednesday, October 29, 2014

How to Save or Export Active Sheet Data into a New Workbook

Excel VBA Macro to Save or Export Active Sheet Data into a New Workbook
Method-I:
Sub Save_ActSht2New_WB()
    ActiveSheet.Copy

    Application.DisplayAlerts = False

    ActiveWorkbook.SaveAs "C:\Users\Tamatam\Desktop\Temp\ActShtData.xlsx"
    ActiveWorkbook.Close True
    
    Application.DisplayAlerts = True
End Sub
----------------------------------------------------------------------------
Method-II:
Sub ExpActSht2New_WB()
'Step 1 Copy the Activesheet data
    ActiveSheet.Cells.Copy
    ActShtName = ActiveSheet.Name

'Step 2 Create a new workbook with Single sheet
    Workbooks.Add (xlWBATWorksheet)

'Step 3 Paste the data and change the sheet name to ActiveSheet Name
    ActiveSheet.Paste
    ActiveSheet.Range("A1").Select
    Application.CutCopyMode = False
    ActiveSheet.Name = ActShtName

'Step 4 Turn off application alerts
    Application.DisplayAlerts = False
    
'Step 5 Save the newly created workbook
    ActiveWorkbook.SaveAs "C:\Users\Tamatam\Desktop\Temp\ActShtData.xlsx"
    ActiveWorkbook.Close True

'Step 6 Turn application alerts back on
    Application.DisplayAlerts = True

End Sub

Thanks, TAMATAM

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog