VBA deleted rows

Ks1102

Well-known Member
Joined
Jan 8, 2008
Messages
689
Hi all

I looking help the VBA code for deleting rows when the cells F3 to down if the value = C then rows deleted,


please help
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi KS1102, perhaps:
Code:
Sub deleteRows()
Dim i as Long
For i = Range("F" & Rows.Count).End(xlUp).Row To 3 Step -1
    If Cells(i, "F").Value = "C" Then Cells(i, "F").EntireRow.Delete
Next i
End Sub
 
Upvote 0
If you have many rows to delete this code may run faster

Code:
Sub DeleteRows()
    Dim c As Range
    Dim rng As Range
    For Each c In Range("F3", Range("F65536").End(xlUp))
        If c = "C" Then
            If rng Is Nothing Then
                Set rng = c
            Else
                Set rng = Union(rng, c)
            End If
        End If
    Next c
    If Not rng Is Nothing Then rng.EntireRow.Delete
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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