Hi
I'm using the following code to save the selection to a new spreadsheet and then save it as import into the same folder as that main spreadsheet.
ActiveSheet.Range("$A$1:$AM$216").AutoFilter Field:=27, Criteria1:=Array( _
"1", "2", "3", "4"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$AM$216").AutoFilter Field:=34, Criteria1:="y"
Columns("A:AF").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.path & "" & Summary & "import.xlsx"
ActiveWorkbook.Close savechanges:=False
End Sub
Unfortunately what's happening is that the macro is saving the new workbook into the same folder as my personal macrobook. Is there a way to avoid this without having to save the macro within the main spreadsheet and keep it inside my personal one?
Cheers
Edit:- Just to add that it is a series of spreadsheets, and so the folder that the import.xlsx needs to go into isn't always going to be at the same location. i.e. there are multiple spreadsheets that this macro will need to work with.
I'm using the following code to save the selection to a new spreadsheet and then save it as import into the same folder as that main spreadsheet.
ActiveSheet.Range("$A$1:$AM$216").AutoFilter Field:=27, Criteria1:=Array( _
"1", "2", "3", "4"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$AM$216").AutoFilter Field:=34, Criteria1:="y"
Columns("A:AF").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.path & "" & Summary & "import.xlsx"
ActiveWorkbook.Close savechanges:=False
End Sub
Unfortunately what's happening is that the macro is saving the new workbook into the same folder as my personal macrobook. Is there a way to avoid this without having to save the macro within the main spreadsheet and keep it inside my personal one?
Cheers
Edit:- Just to add that it is a series of spreadsheets, and so the folder that the import.xlsx needs to go into isn't always going to be at the same location. i.e. there are multiple spreadsheets that this macro will need to work with.
Last edited: