Guna13
Board Regular
- Joined
- Nov 22, 2019
- Messages
- 70
- Office Version
- 365
- Platform
- Windows
I tried to save my Active work with .Xlsm but I got an Out of Memory error or my Active work was automatically closed. Can't accomplish this task?
As a result of making multiple .Xlsm workbooks. The end user will update the information, then run the final macro. I need to keep this active workbook module.Code in split files as well.
As a result of making multiple .Xlsm workbooks. The end user will update the information, then run the final macro. I need to keep this active workbook module.Code in split files as well.
VBA Code:
Sub FileSplit()
Set ws = ThisWorkbook.Worksheets("Segment TB workings")
On Error Resume Next
ThisWorkbook.Sheets("Sdata").Delete
On Error GoTo 0
ws.Activate
ws.AutoFilterMode = False
Dim i As Long, sh As Worksheet, sh2 As Worksheet
Set sh2 = Sheets.Add(After:=ws)
sh2.Name = "Sdata"
Sheets("Segment TB workings").Range("O1:O100000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sdata").Range("A1"), CopyToRange:=Range("A1"), _
Unique:=True
lr = Cells(Rows.Count, "A").End(xlUp).Row 'find last row
For i = lr To 2 Step -1 'loop thru backwards, finish at 2 for headers
If Cells(i, "A").Text = "#N/A" Then Rows(i).EntireRow.Delete
Next i
numrows = Range("A2", Range("A2").End(xlDown)).Rows.Count
i = 2
Do Until i > numrows
Set IndName = Worksheets("Sdata").Cells(i, 1)
With ActiveWorkbook
.SaveAs Filename:="C:\Statutory Audit Report\SourceFiles\" & IndName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
.Close 0
End With
i = i + 1
Loop
End Sub