Solved: read from list and delete rows if cells contains expression from that list
[VBA]
ub Read_text_File()
Dim oFSO As New FileSystemObject
Dim oFS
Dim luka As Range
Set oFS = oFSO.OpenTextFile("C:\list.txt")
Do Until oFS.AtEndOfStream
STEXT = oFS.ReadLine
R = ActiveSheet.UsedRange.Rows.Count
Range("A1").Select
For i = 1 To R
Set luka = Cells.Find(What:=STEXT, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not luka Is Nothing Then
If STEXT = "" Then
GoTo znova
End If
luka.Select
Selection.Delete shift:=xlUp
ActiveCell.Offset(-1, 0).Select
'End If
Else
GoTo znova:
End If
Next i
znova:
'End If
Loop
R = ActiveSheet.UsedRange.Rows.Count
Range("A1").Select
'For i = 1 To R
On Error Resume Next ' In case there are no blanks
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
' Next i
End Sub[/VBA]
I have a normal txt file which software names in each line
(actually not full software name but just partial name e.g : instead microsoft office I have just microsoft)
So when this keyword is found in excel row whole row should get deleted, so leaving no empty rows, but for some reason it doesnt work well, I found that a lot entries are deleted even if keyword is not in txt file)
thank you very much for your answers