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:
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