![]() |
Macro to delete row
Hi, i need a macro to delete rows that don't have in "H" column the name "John"
If in "H" column the code finds anything else, then to delete row. Can this be done? Thanks! |
Macro to delete row
Hi,
One approach might be: ================= Sub John() LR = [H65536].End(xlUp).Row For R = LR To 1 Step -1 If Cells(R, 8) < "John" Then Cells(R, 8).EntireRow.Delete Next End Sub ======== Micky "puiuluipui" wrote: Hi, i need a macro to delete rows that don't have in "H" column the name "John" If in "H" column the code finds anything else, then to delete row. Can this be done? Thanks! |
Macro to delete row
Hi
'Delete if not cell match Sub DeleteRows() Dim lngRow As Long For lngRow = Cells(Rows.Count, "H").End(xlUp).Row To 1 Step -1 If StrComp(Range("H" & lngRow), "John", vbTextCompare) < 0 Then Rows(lngRow).Delete End If Next End Sub 'delete rows if the word 'john' is not found within the cell Sub DeleteRows() Dim lngRow As Long For lngRow = Cells(Rows.Count, "H").End(xlUp).Row To 1 Step -1 If InStr(1, Range("H" & lngRow), "john", vbTextCompare) = 0 Then Rows(lngRow).Delete End If Next End Sub -- Jacob "puiuluipui" wrote: Hi, i need a macro to delete rows that don't have in "H" column the name "John" If in "H" column the code finds anything else, then to delete row. Can this be done? Thanks! |
Macro to delete row
sub delifnotjohn()'if John is not within other text for i=cells(rows.count,"H").end(xlup).row to 1 step -1 if ucase(cells(i,"h"))<"JOHN" then rows(i).delete next i end sub -- Don Guillett Microsoft MVP Excel SalesAid Software "puiuluipui" wrote in message ... Hi, i need a macro to delete rows that don't have in "H" column the name "John" If in "H" column the code finds anything else, then to delete row. Can this be done? Thanks! |
All times are GMT +1. The time now is 02:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com