micropscotts
New Member
- Joined
- Aug 6, 2014
- Messages
- 1
Hi guys,
I have a spreadsheet with several sheets which I am having a few problems with. Basically I have set up the below code so that VBA will apply an autofilter which looks for a certain criteria in a column and then cuts and pastes the relevant row to the next sheet before deleting the row in the first sheet and moving the rows up. The criteria that the autofilter looks for is "Yes."
Basically the problem I am encountering is that when I click the update button, it cuts and pastes the column header as well as the update button into the next sheet which obviously I don't want it to do.
Can anyone please point me in the right direction with this?
Many thanks
I have a spreadsheet with several sheets which I am having a few problems with. Basically I have set up the below code so that VBA will apply an autofilter which looks for a certain criteria in a column and then cuts and pastes the relevant row to the next sheet before deleting the row in the first sheet and moving the rows up. The criteria that the autofilter looks for is "Yes."
Code:
Option ExplicitSub Button11_Click()
Application.ScreenUpdating = False
Columns(14).AutoFilter 1, "Yes" '// Applies an autofilter to the 14th column (Col N), filters for value "Yes"
With Range("a2", Range("n" & Rows.Count).End(3)) '// This range is all the data, when using autofilter no need to specify visible cells
.Copy Sheet5.Cells(Rows.Count, 1).End(3).Offset(1) '// Copies all the rows on Sheet4 which were filtered, pastes to first available row on Sheet5
.EntireRow.Delete '// Deletes all the rows on Sheet3 which were filtered
End With
Columns(14).AutoFilter '// Removes the autofilter
Application.ScreenUpdating = True
End Sub
Basically the problem I am encountering is that when I click the update button, it cuts and pastes the column header as well as the update button into the next sheet which obviously I don't want it to do.
Can anyone please point me in the right direction with this?
Many thanks