Hi, I'm currently working on a macro which would allow me to cut & paste filtered data from one sheet to another, then come back to the original sheet and get rid of the blank rows that are left. Originally, I was able to get around the problem of cutting unwanted data by sorting several columns and then it somehow worked but now the order of data is more random and from the research I've done, it looks like I'll have to use 'special cells'. However, I can't get it work properly and the macro now crashes on the 'Cut' line.
I'd greatly appreciate if you could please help me out with this.
I know there are most likely better, more efficient ways to go about this than what I've done above so by all means feel free to change/remove code.
Thanks in advance!
I'd greatly appreciate if you could please help me out with this.
Code:
Application.ScreenUpdating = False
Sheets("SheetX").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("SheetX".AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("SheetX".AutoFilter.Sort.SortFields.Add Key:= _
Range("I1", SortOn:=xlSortOnValues, Order:= xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("SheetX".AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$W$1").AutoFilter Field:=10, Criteria 1:="=Criteria 1" xlOr Criteria 2:="=Criteria 2"
ActiveSheet.Range("$A$1:$W$1").AutoFilter Field:=12, Criteria 1:="=*Criteria Y*"
Range("A2:W2).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Cut
Sheets("SheetZ").Select
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1,0).Range("A1").Select
ActiveSheet.Paste
Sheets("SheetX").Select
Selection.EntireRow.Delete
Selection.AutoFilter
Application.ScreenUpdating = True
I know there are most likely better, more efficient ways to go about this than what I've done above so by all means feel free to change/remove code.
Thanks in advance!