djmnon
New Member
- Joined
- Mar 22, 2022
- Messages
- 19
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
I have a macro which I have created which basically filters out the data and copy pastes it into 2 different sheets (this is standard).
So whenever I run the Macro say 1st time it will show as Sheet1 and Sheet2
Whenever I run the Macro say 2nd time it shows as Sheet3 and Sheet4
Expected Result.
Everytime I run the Macro it the sheet names should be as Sheet1 and Sheet2
How do I do this?
Below is the Macro :- this is a Recorded Macro want to modify it by renaming the file names to Sheet1 and Sheet2 everytime
Sub dave()
'
' dave Macro
'
'
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$9995").AutoFilter Field:=8, Criteria1:= _
"Home Office"
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Orders").Select
ActiveWindow.ScrollRow = 9851
ActiveWindow.ScrollRow = 9761
ActiveWindow.ScrollRow = 9656
ActiveWindow.ScrollRow = 9536
ActiveWindow.ScrollRow = 9372
ActiveWindow.ScrollRow = 8698
ActiveWindow.ScrollRow = 8473
ActiveWindow.ScrollRow = 7785
ActiveWindow.ScrollRow = 5704
ActiveWindow.ScrollRow = 5030
ActiveWindow.ScrollRow = 4851
ActiveWindow.ScrollRow = 4312
ActiveWindow.ScrollRow = 4012
ActiveWindow.ScrollRow = 3578
ActiveWindow.ScrollRow = 3444
ActiveWindow.ScrollRow = 3234
ActiveWindow.ScrollRow = 3144
ActiveWindow.ScrollRow = 2935
ActiveWindow.ScrollRow = 2830
ActiveWindow.ScrollRow = 2560
ActiveWindow.ScrollRow = 1707
ActiveWindow.ScrollRow = 1497
ActiveWindow.ScrollRow = 1378
ActiveWindow.ScrollRow = 1273
ActiveWindow.ScrollRow = 1213
ActiveWindow.ScrollRow = 1138
ActiveWindow.ScrollRow = 1093
ActiveWindow.ScrollRow = 1063
ActiveWindow.ScrollRow = 1048
ActiveWindow.ScrollRow = 1018
ActiveWindow.ScrollRow = 1003
ActiveWindow.ScrollRow = 989
ActiveWindow.ScrollRow = 974
ActiveWindow.ScrollRow = 959
ActiveWindow.ScrollRow = 914
ActiveWindow.ScrollRow = 884
ActiveWindow.ScrollRow = 809
ActiveWindow.ScrollRow = 779
ActiveWindow.ScrollRow = 704
ActiveWindow.ScrollRow = 644
ActiveWindow.ScrollRow = 569
ActiveWindow.ScrollRow = 524
ActiveWindow.ScrollRow = 495
ActiveWindow.ScrollRow = 465
ActiveWindow.ScrollRow = 450
ActiveWindow.ScrollRow = 420
ActiveWindow.ScrollRow = 390
ActiveWindow.ScrollRow = 345
ActiveWindow.ScrollRow = 315
ActiveWindow.ScrollRow = 285
ActiveWindow.ScrollRow = 240
ActiveWindow.ScrollRow = 210
ActiveWindow.ScrollRow = 180
ActiveWindow.ScrollRow = 135
ActiveWindow.ScrollRow = 105
ActiveWindow.ScrollRow = 90
ActiveWindow.ScrollRow = 60
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 1
ActiveSheet.Range("$A$1:$U$9995").AutoFilter Field:=13, Criteria1:="East"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A98").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Orders").Select
End Sub
So whenever I run the Macro say 1st time it will show as Sheet1 and Sheet2
Whenever I run the Macro say 2nd time it shows as Sheet3 and Sheet4
Expected Result.
Everytime I run the Macro it the sheet names should be as Sheet1 and Sheet2
How do I do this?
Below is the Macro :- this is a Recorded Macro want to modify it by renaming the file names to Sheet1 and Sheet2 everytime
Sub dave()
'
' dave Macro
'
'
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$9995").AutoFilter Field:=8, Criteria1:= _
"Home Office"
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Orders").Select
ActiveWindow.ScrollRow = 9851
ActiveWindow.ScrollRow = 9761
ActiveWindow.ScrollRow = 9656
ActiveWindow.ScrollRow = 9536
ActiveWindow.ScrollRow = 9372
ActiveWindow.ScrollRow = 8698
ActiveWindow.ScrollRow = 8473
ActiveWindow.ScrollRow = 7785
ActiveWindow.ScrollRow = 5704
ActiveWindow.ScrollRow = 5030
ActiveWindow.ScrollRow = 4851
ActiveWindow.ScrollRow = 4312
ActiveWindow.ScrollRow = 4012
ActiveWindow.ScrollRow = 3578
ActiveWindow.ScrollRow = 3444
ActiveWindow.ScrollRow = 3234
ActiveWindow.ScrollRow = 3144
ActiveWindow.ScrollRow = 2935
ActiveWindow.ScrollRow = 2830
ActiveWindow.ScrollRow = 2560
ActiveWindow.ScrollRow = 1707
ActiveWindow.ScrollRow = 1497
ActiveWindow.ScrollRow = 1378
ActiveWindow.ScrollRow = 1273
ActiveWindow.ScrollRow = 1213
ActiveWindow.ScrollRow = 1138
ActiveWindow.ScrollRow = 1093
ActiveWindow.ScrollRow = 1063
ActiveWindow.ScrollRow = 1048
ActiveWindow.ScrollRow = 1018
ActiveWindow.ScrollRow = 1003
ActiveWindow.ScrollRow = 989
ActiveWindow.ScrollRow = 974
ActiveWindow.ScrollRow = 959
ActiveWindow.ScrollRow = 914
ActiveWindow.ScrollRow = 884
ActiveWindow.ScrollRow = 809
ActiveWindow.ScrollRow = 779
ActiveWindow.ScrollRow = 704
ActiveWindow.ScrollRow = 644
ActiveWindow.ScrollRow = 569
ActiveWindow.ScrollRow = 524
ActiveWindow.ScrollRow = 495
ActiveWindow.ScrollRow = 465
ActiveWindow.ScrollRow = 450
ActiveWindow.ScrollRow = 420
ActiveWindow.ScrollRow = 390
ActiveWindow.ScrollRow = 345
ActiveWindow.ScrollRow = 315
ActiveWindow.ScrollRow = 285
ActiveWindow.ScrollRow = 240
ActiveWindow.ScrollRow = 210
ActiveWindow.ScrollRow = 180
ActiveWindow.ScrollRow = 135
ActiveWindow.ScrollRow = 105
ActiveWindow.ScrollRow = 90
ActiveWindow.ScrollRow = 60
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 1
ActiveSheet.Range("$A$1:$U$9995").AutoFilter Field:=13, Criteria1:="East"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A98").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Orders").Select
End Sub