VBA to Copy Row with Criteria to Another Sheet

dmlin335

New Member
Joined
Apr 17, 2013
Messages
2
I am a new VBA coder and am having difficulty executing what is probably a very simple task. Any help would be much appreciated!

In column D of an excel sheet, there are a number of drop-down choices from a list. I am looking to create a button macro that will filter out all cells in Column D that = "Follow-Up". I then want it to copy that entire row to another sheet in the same workbook and add it at the first available blank row. Ideally, each time I hit the button, my list of "Follow-Up" rows gets longer with more data. Below is the code I am using, but nothing is populating in Sheet2. Help please!

Sub NewSheetData()


With Application
.ScreenUpdating = False
.EnableEvents = False
End With


Dim Rng As Range, arCrits(), l As Long


Set Rng = Range([D1], Range("d" & Rows.Count).End(xlUp))
arCrits = Array("Process") 'add more criteria to the array as required


For l = 0 To UBound(arCrits)
On Error Resume Next
With Rng
.AutoFilter , field:=1, Criteria1:=arCrits(l)
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Copy ["Sheet2"].Range("D" & Rows.Count).End(xlUp).Offset(1)
.AutoFilter
End With
On Error GoTo 0
Next l


Application.EnableEvents = True


End Sub
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi, try recording that process with the auto filter function. I have a similar project I did last year. you should be able to edit that code to work for you.
 

dmlin335

New Member
Joined
Apr 17, 2013
Messages
2
Hi, try recording that process with the auto filter function. I have a similar project I did last year. you should be able to edit that code to work for you.

Thanks Mark. Can you clarify what you mean? I have autofilter nested in my loop.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,414
Messages
5,596,001
Members
414,037
Latest member
Roamingsmile

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
Top