Hi,
I currently have 2 steps of code which work fine but I want it to work off of one button press to take the data from one workbook to multiple other workbooks and save as per the name.
The first set of code filters it but puts them into sheets and the second set of code converts those sheets into workbooks, but it also includes the sheet which has the data on which I don't want.
If I can get some assistance on this, much appreciated.
Please see code below:
1.
2.
I currently have 2 steps of code which work fine but I want it to work off of one button press to take the data from one workbook to multiple other workbooks and save as per the name.
The first set of code filters it but puts them into sheets and the second set of code converts those sheets into workbooks, but it also includes the sheet which has the data on which I don't want.
If I can get some assistance on this, much appreciated.
Please see code below:
1.
VBA Code:
Sub Filter_Data()
Dim R As Integer, ADM As String, wb As Worksheet
Set ws = ActiveSheet
ws.Range("A1:G1").AutoFilter
R = 1
Do
R = R + 1
ADM = ws.Range("G" & R).Value
On Error Resume Next
If Sheets(ADM) Is Nothing Then
ws.Range("A1:G1").AutoFilter Field:=7, Criteria1:=ADM
ws.Range("G1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add.Name = ADM
Sheets(ADM).Paste
Columns("A:G").AutoFit
ws.ShowAllData
End If
Loop While ws.Range("G" & R + 1).Value <> ""
End Sub
2.
VBA Code:
Sub Folder_Creation()
Dim ws As Worksheet
Dim wbPath As String
wbPath = ThisWorkbook.path
For Each ws In ThisWorkbook.Worksheets
ws.Copy
With ActiveWorkbook
.SaveAs Filename:="C:\Users\Reports\" & ws.Name
.Close
End With
Next
End Sub
Last edited by a moderator: