ExcelPupper
Board Regular
- Joined
- Mar 2, 2020
- Messages
- 112
- Office Version
- 2019
- Platform
- Windows
I have here my code that does not run properly because when I press F5 it only copies the data from the top row, but when I do the step into (F8) it works fine. Is there something I should modify on the code below?
VBA Code:
Sub CopyData()
'
'
' Keyboard Shortcut: Ctrl+Shift+Q
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Sheets(1).Activate
ActiveSheet.Range("A1:D" & LR).AutoFilter Field:=1, Criteria1:="High"
ActiveSheet.Range("A1:D" & LR).AutoFilter Field:=2, Criteria1:="1000"
ActiveSheet.Range("A1:D" & LR).AutoFilter Field:=3, Criteria1:="10"
Range("A1:D" & LR).Select
Selection.Copy
Sheets("Class1").Select
ActiveSheet.Paste
Sheets(1).Select
ActiveSheet.Range("$A$1:D" & LR).AutoFilter Field:=3, Criteria1:="11"
Range("A1:D" & LR).Select
Selection.Copy
Sheets("Class2").Select
ActiveSheet.Paste
End Sub