jesuscares
New Member
- Joined
- Jun 10, 2015
- Messages
- 25
Hello guys
I am in need of your assistance. I have spreadsheet with 10 columns (i.e A to J). In column A, I need to remove any entries with the term "FILE" and in column C, any entries with the term "NEWS". The end result of this process should be removal of the associated rows. At the moment, I have setup the following code to remove only the rows based on column A containing entries with the term "FILE". It is as follows:
Sub Sample()
Dim ws As Worksheet
Dim lRow As Long
Dim strSearch As String
'~~> Set this to the relevant worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
'~~> Search Text
strSearch = "FILE"
With ws
'~~> Remove any filters
.AutoFilterMode = False
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
With .Range("A1:A" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
End Sub
My question is therefore, how should I amend the existing code to include the removal of the term "NEWS" in column C? Ideally, I would like for both processes to occur concurrently so that my output would reflect the removal of the rows with both terms. I greatly appreciate any help!
I am in need of your assistance. I have spreadsheet with 10 columns (i.e A to J). In column A, I need to remove any entries with the term "FILE" and in column C, any entries with the term "NEWS". The end result of this process should be removal of the associated rows. At the moment, I have setup the following code to remove only the rows based on column A containing entries with the term "FILE". It is as follows:
Sub Sample()
Dim ws As Worksheet
Dim lRow As Long
Dim strSearch As String
'~~> Set this to the relevant worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
'~~> Search Text
strSearch = "FILE"
With ws
'~~> Remove any filters
.AutoFilterMode = False
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
With .Range("A1:A" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
End Sub
My question is therefore, how should I amend the existing code to include the removal of the term "NEWS" in column C? Ideally, I would like for both processes to occur concurrently so that my output would reflect the removal of the rows with both terms. I greatly appreciate any help!