sharkey
New Member
Good morning all,
I think I have the meat and potatoes for this from my extensive Google research, just need a little help combining what I have. Currently I have two macros that look at two separate worksheets and parse them into separate files based off of common values. My first macro does the "account summary" tab (has data in columns A-R), and then my second macro does the "account details" tab (has data in columns A-H). My end goal here would for the macro to do the actions of both of these macros, but save the two worksheets in one common file instead of two separate files. Any help on this would be greatly appreciated! My current macros are pasted below...
Thanks in advance!
Sharkey
Option Explicit
Sub ParseItemsAcctSumm()
Dim LR As Long, Itm As Long, MyCount As Long, vCol As Long
Dim ws As Worksheet, MyArr As Variant, vTitles As String, SvPath As String
Set ws = Sheets("Account Summary")
SvPath = "C:\Users\jonathan.sharkey\Desktop\Test_Folder\Account_Summary\"
vTitles = "A1:R1"
vCol = 1
LR = ws.Cells(ws.Rows.Count, vCol).End(xlUp).Row
Application.ScreenUpdating = False
ws.Columns(vCol).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ws.Range("EE1"), Unique:=True
ws.Columns("EE:EE").Sort Key1:=ws.Range("EE2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
MyArr = Application.WorksheetFunction.Transpose(ws.Range("EE2:EE" & Rows.Count).SpecialCells(xlCellTypeConstants))
ws.Range("EE:EE").Clear
ws.Range(vTitles).AutoFilter
For Itm = 1 To UBound(MyArr)
ws.Range(vTitles).AutoFilter Field:=vCol, Criteria1:=MyArr(Itm)
ws.Range("A1:A" & LR).EntireRow.Copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
Cells.Columns.AutoFit
MyCount = MyCount + Range("A" & Rows.Count).End(xlUp).Row - 1
ActiveWorkbook.SaveAs SvPath & MyArr(Itm) & " Account Summary" & Format(Date, " MM-DD-YY"), xlOpenXMLWorkbook
ActiveWorkbook.Close False
ws.Range(vTitles).AutoFilter Field:=vCol
Next Itm
End Sub
Sub ParseItemsAcctDetails()
Dim LR As Long, Itm As Long, MyCount As Long, vCol As Long
Dim ws As Worksheet, MyArr As Variant, vTitles As String, SvPath As String
Set ws = Sheets("Account Details")
SvPath = "C:\Users\jonathan.sharkey\Desktop\Test_Folder\Account_Details\"
vTitles = "A1:H1"
vCol = 1
LR = ws.Cells(ws.Rows.Count, vCol).End(xlUp).Row
Application.ScreenUpdating = False
ws.Columns(vCol).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ws.Range("EE1"), Unique:=True
ws.Columns("EE:EE").Sort Key1:=ws.Range("EE2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
MyArr = Application.WorksheetFunction.Transpose(ws.Range("EE2:EE" & Rows.Count).SpecialCells(xlCellTypeConstants))
ws.Range("EE:EE").Clear
ws.Range(vTitles).AutoFilter
For Itm = 1 To UBound(MyArr)
ws.Range(vTitles).AutoFilter Field:=vCol, Criteria1:=MyArr(Itm)
ws.Range("A1:A" & LR).EntireRow.Copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
Cells.Columns.AutoFit
MyCount = MyCount + Range("A" & Rows.Count).End(xlUp).Row - 1
ActiveWorkbook.SaveAs SvPath & MyArr(Itm) & " Account Details" & Format(Date, " MM-DD-YY"), xlOpenXMLWorkbook
ActiveWorkbook.Close False
ws.Range(vTitles).AutoFilter Field:=vCol
Next Itm
End Sub
I think I have the meat and potatoes for this from my extensive Google research, just need a little help combining what I have. Currently I have two macros that look at two separate worksheets and parse them into separate files based off of common values. My first macro does the "account summary" tab (has data in columns A-R), and then my second macro does the "account details" tab (has data in columns A-H). My end goal here would for the macro to do the actions of both of these macros, but save the two worksheets in one common file instead of two separate files. Any help on this would be greatly appreciated! My current macros are pasted below...
Thanks in advance!
Sharkey
Option Explicit
Sub ParseItemsAcctSumm()
Dim LR As Long, Itm As Long, MyCount As Long, vCol As Long
Dim ws As Worksheet, MyArr As Variant, vTitles As String, SvPath As String
Set ws = Sheets("Account Summary")
SvPath = "C:\Users\jonathan.sharkey\Desktop\Test_Folder\Account_Summary\"
vTitles = "A1:R1"
vCol = 1
LR = ws.Cells(ws.Rows.Count, vCol).End(xlUp).Row
Application.ScreenUpdating = False
ws.Columns(vCol).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ws.Range("EE1"), Unique:=True
ws.Columns("EE:EE").Sort Key1:=ws.Range("EE2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
MyArr = Application.WorksheetFunction.Transpose(ws.Range("EE2:EE" & Rows.Count).SpecialCells(xlCellTypeConstants))
ws.Range("EE:EE").Clear
ws.Range(vTitles).AutoFilter
For Itm = 1 To UBound(MyArr)
ws.Range(vTitles).AutoFilter Field:=vCol, Criteria1:=MyArr(Itm)
ws.Range("A1:A" & LR).EntireRow.Copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
Cells.Columns.AutoFit
MyCount = MyCount + Range("A" & Rows.Count).End(xlUp).Row - 1
ActiveWorkbook.SaveAs SvPath & MyArr(Itm) & " Account Summary" & Format(Date, " MM-DD-YY"), xlOpenXMLWorkbook
ActiveWorkbook.Close False
ws.Range(vTitles).AutoFilter Field:=vCol
Next Itm
End Sub
Sub ParseItemsAcctDetails()
Dim LR As Long, Itm As Long, MyCount As Long, vCol As Long
Dim ws As Worksheet, MyArr As Variant, vTitles As String, SvPath As String
Set ws = Sheets("Account Details")
SvPath = "C:\Users\jonathan.sharkey\Desktop\Test_Folder\Account_Details\"
vTitles = "A1:H1"
vCol = 1
LR = ws.Cells(ws.Rows.Count, vCol).End(xlUp).Row
Application.ScreenUpdating = False
ws.Columns(vCol).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ws.Range("EE1"), Unique:=True
ws.Columns("EE:EE").Sort Key1:=ws.Range("EE2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
MyArr = Application.WorksheetFunction.Transpose(ws.Range("EE2:EE" & Rows.Count).SpecialCells(xlCellTypeConstants))
ws.Range("EE:EE").Clear
ws.Range(vTitles).AutoFilter
For Itm = 1 To UBound(MyArr)
ws.Range(vTitles).AutoFilter Field:=vCol, Criteria1:=MyArr(Itm)
ws.Range("A1:A" & LR).EntireRow.Copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
Cells.Columns.AutoFit
MyCount = MyCount + Range("A" & Rows.Count).End(xlUp).Row - 1
ActiveWorkbook.SaveAs SvPath & MyArr(Itm) & " Account Details" & Format(Date, " MM-DD-YY"), xlOpenXMLWorkbook
ActiveWorkbook.Close False
ws.Range(vTitles).AutoFilter Field:=vCol
Next Itm
End Sub