ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete rows in Table (https://www.excelbanter.com/excel-programming/447679-delete-rows-table.html)

Bakar

Delete rows in Table
 
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 all empty rows
with vba

Thanks for ur usual help

Bakar

Thanks very much you r the best

Claus Busch

Delete rows in Table
 
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com