Hello All,
I posted a previous thread, but I think I didn't offer enough evidence that I've tried to figure out the code I need to use to accomplish the task I need it to. In that effort I recorded a macro to see if it would at least give me the base code to view in order to make changes to suit what it is that I need the macro to do. However, upon looking at the base code, I'm having a little difficulty understanding how it's doing what I recorded, because I don't see any DIM declarations. I also see where it covers a range, however it doesn't look like previous code I've used when selecting a range. Here is the code that I got when recording the macro:
Previous code I've used when copying data :
Essentially, I'm trying to filter my data within multiple columns, copy it, and then paste it within a new workbook. Once data has been pasted into a new workbook, I would like to save the new workbook with a generic name that changes based on the current date and Region Name.
I appreciate any tips or information that can point me in the right direction. Thank you.
D.
I posted a previous thread, but I think I didn't offer enough evidence that I've tried to figure out the code I need to use to accomplish the task I need it to. In that effort I recorded a macro to see if it would at least give me the base code to view in order to make changes to suit what it is that I need the macro to do. However, upon looking at the base code, I'm having a little difficulty understanding how it's doing what I recorded, because I don't see any DIM declarations. I also see where it covers a range, however it doesn't look like previous code I've used when selecting a range. Here is the code that I got when recording the macro:
VBA Code:
Sub FilterDataCopyPasteSave()
'
' FilterDataCopyPasteSave Macro
' Filter by Region; copy data; paste in new workbook; save new workbook
ActiveSheet.ListObjects("Table6").Range.AutoFilter Field:=3, Criteria1:= _
"Region Name"
ActiveSheet.ListObjects("Table6").Range.AutoFilter Field:=5, Criteria1:= _
"Open"
ActiveSheet.ListObjects("Table6").Range.AutoFilter Field:=4, Criteria1:= _
Array("Store Types"), Operator:=xlFilterValues
Range("Table6[[#Headers],[Store Id]]").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Application.CutCopyMode = False
ChDir "C:\Users\NTID Login\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\NTID Login\Desktop\POC Region 3.30.2021.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Save
ActiveWindow.SmallScroll Down:=-39
ActiveWindow.Close
Application.ActiveProtectedViewWindow.Edit
ActiveWindow.Close
Application.ActiveProtectedViewWindow.Edit
End Sub
Previous code I've used when copying data :
Code:
Sub Treat1()
Dim WkRg As Range
Dim Objdic As Object
Dim E As Range
With Sheets("AllData")
.Range("AE2:AE" & .Range("AE" & Rows.Count).End(xlUp).Row).Copy _
'looking to paste the copied data in to a new workbook, not a worksheet'
Destination:=Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(0, 0)
End With
Set WkRg = Sheets("Sheet1").Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
With CreateObject("Scripting.Dictionary")
For Each E In WkRg
.Item(E.Value) = Empty
Next E
WkRg.Clear
Sheets("Sheet1").Cells(1, 1).Resize(.Count, 1) = Application.Transpose(.Keys)
End With
End Sub
Essentially, I'm trying to filter my data within multiple columns, copy it, and then paste it within a new workbook. Once data has been pasted into a new workbook, I would like to save the new workbook with a generic name that changes based on the current date and Region Name.
Code:
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\NTID Login\Desktop\POC Region Name & Format(Date, "mm.dd.yyyy")& ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
I appreciate any tips or information that can point me in the right direction. Thank you.
D.