delete specific data

A

Armand

Hi evryeone i need some help to create a VBA code for delete a row with
content specific data i meade this but does't work.
let me know your answers
Thanks folks

Sub DeleteRowsBasedOnCriteria1()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="127595"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="127597"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="129079"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="HS111"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:=" "
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="Monterrey"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="Dana"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="Dana
Heavy Axl"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="Component"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("a1").AutoFilter Field:=1, Criteria1:=" "
.Range("a1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria2()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("B1").AutoFilter Field:=1,
Criteria1:="Grasa*"
.Range("B1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria3()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("H1").AutoFilter Field:=1, Criteria1:="<0"
.Range("H1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria4()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("k1").AutoFilter Field:=1, Criteria1:="0"
.Range("k1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria5()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("M1").AutoFilter Field:=1, Criteria1:="P"
.Range("M1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
 
J

Jeff Boyce

Armand

Your code appears to be for a spreadsheet. This newsgroup supports
Microsoft Access, the relational database product.

Consider posting to an Excel newsgroup...

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hi evryeone i need some help to create a VBA code for delete a row with
content specific data i meade this but does't work.
let me know your answers
Thanks folks

Sub DeleteRowsBasedOnCriteria1()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="127595"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="127597"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="129079"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="HS111"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:=" "
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="Monterrey"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="Dana"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="Dana
Heavy Axl"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1,
Criteria1:="Component"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("a1").AutoFilter Field:=1, Criteria1:=" "
.Range("a1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria2()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("B1").AutoFilter Field:=1,
Criteria1:="Grasa*"
.Range("B1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria3()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("H1").AutoFilter Field:=1, Criteria1:="<0"
.Range("H1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria4()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("k1").AutoFilter Field:=1, Criteria1:="0"
.Range("k1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Sub DeleteRowsBasedOnCriteria5()
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("M1").AutoFilter Field:=1, Criteria1:="P"
.Range("M1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
 

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