Button to remove rows

The Animal

Active Member
Joined
May 26, 2011
Messages
449
Hi.
I have a filter on column "A" with Enable and Disable options via Data validation list.
I would like to create a macro that removes all rows flagged "Disable" and place them in rows 200 onwards.
So as we disable a row that disable row just goes onto the bottom of the list from row 200 onwards.

Thanks Stephen
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
.
Here is one way ....

Code:
Sub CopyYes()
   Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target As Worksheet
    Application.ScreenUpdating = False
    ' Change worksheet designations as needed
    Set Source = ActiveWorkbook.Worksheets("Sheet1")
    Set Target = ActiveWorkbook.Worksheets("Sheet1")
    
    Application.ScreenUpdating = False
    Target.Select
    
    With Target
        .Rows("1:199").Select
        'Selection.Delete Shift:=xlUp
    End With
    
    Source.Select
    j = 200   ' Start copying to row 1 in target sheet
    
    For Each c In Source.Range("A1:A199")   ' Do 1000 rows
        If c.Value = "Disabled" Then
           Source.Rows(c.Row).Copy Target.Rows(j)
        End If
        
        If c.Value = "Disabled" Then
           Source.Rows(c.Row).Delete
        End If
        
    Next c
        
    Target.Select
    Target.Range("A1").Select
    
    Worksheets(1).Calculate
    
    'Application.CutCopyMode = False
    Source.Select
    Source.Range("A1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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