Cut & Paste Special Cells from Sheet 1 to Sheet 2, Then Delete Blanks

Frenzyy

New Member
Joined
May 26, 2019
Messages
24
Office Version
  1. 365
Platform
  1. Windows
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.


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!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top