VBA to create new workbook + save ... then resume loop

Mr Retirement

New Member
Joined
Nov 12, 2016
Messages
46
Hi Everyone -

I am trying have a loop in which after each 'loop' copy a particular tab ("Summary") and create its own workbook + save it + then resume the loop in the original file. Is this then possible?

This part of the code below I think I need something different because this will just save it to the folder and not its own file.

ActiveWorkbook.SaveAs DesktopAddress & "\RM Reports" & x & ".xlsx"

Thanks in advance for any advice!!
Mr R.


What I have currently:

Code:
Sub SaveFilesLoop()  

    Dim DesktopAddress As String
    DesktopAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator

'Create Folder on Desktop    
    MkDir DesktopAddress & "\Reports"

'Define
    Dim XRow As Long
    Sheets("List").Select
    XRow = Cells(Rows.Count, 1).End(xlUp).Row

'Starting Loop
    Sheets("List").Select
    Dim x As Range
    For Each x In Range("A2:A" & XRow)
                 
'Paste and Refresh x
    Sheets("Details").Range("C3").Select
    ActiveCell.FormulaR1C1 = x
            
'Copies Tab into Ending Table (Values)
    Application.CutCopyMode = False
    Sheets("Details").Cells.Copy
    Sheets("Summary").Select
    Range("A1").Select
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
'Need Code to Take the Summary Tab... Copy it to a new workbook & save it to the below location
    ActiveWorkbook.SaveAs DesktopAddress & "\RM Reports\" & x & ".xlsx"

'Continues Loop
    Next

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How about
Code:
'Need Code to Take the Summary Tab... Copy it to a new workbook & save it to the below location
   Sheets("Summary").Copy
   ActiveWorkbook.SaveAs DesktopAddress & "\RM Reports\" & x & ".xlsx"
   ActiveWorkbook.Close False
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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