Delete rows in Table

B

Bakar

Hi Everyone
I have a table with column A to J fill with data
and in column F i have Inactive and Active
I want to delete only rows that is Inactive and the active fill al
empty rows
with vba

Thanks for ur usual help

Baka
 
C

Claus Busch

Hi,

Am Sun, 18 Nov 2012 13:28:46 +0000 schrieb Bakar:
I have a table with column A to J fill with data
and in column F i have Inactive and Active
I want to delete only rows that is Inactive and the active fill all
empty rows
with vba

try:
Sub Test1()
Dim LRow As Long
Dim SRow As Long

With ActiveSheet
LRow = .Cells(.Rows.Count, "F").End(xlUp).Row
..Range("A1:J" & LRow).Sort Key1:=Range("F1"), _
Order1:=xlAscending, Header:=xlYes
SRow = WorksheetFunction.Match("Inactive", Range("F1:F" & LRow), 0)
.Rows(SRow & ":" & LRow).Delete
End With
End Sub

or:
Sub Test2()
Dim LRow As Long
Dim i As Long

LRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = LRow To 2 Step -1
If Cells(i, "F") = "Inactive" Then
Rows(i).Delete
End If
Next
End Sub


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top