ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete row problem (https://www.excelbanter.com/excel-programming/439844-delete-row-problem.html)

Seeker

Delete row problem
 
First 3 criteria work but not the 4th, which is looking cells in column "J"
with all start of "HG", anybody can help please?

Sub Macro1()
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "I") = "" Or Cells(i, "J") = "sss" Or Cells(i, "J") =
"ccccc" Or Cells(i, "J") = "//" Or Cells(i, "J") = "HG*" Then
Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub


OssieMac

Delete row problem
 

Change = to Like if using wild cards.

Cells(i, "J") Like "HG*" Then

Also note that due to case sensitive in the comparison with = etc you might
have to convert the value to uppercase or lower case for the purpose of the
comparison like the following.

UCase(Cells(i, "J")) Like "HG*" Then


--
Regards,

OssieMac


"Seeker" wrote:

First 3 criteria work but not the 4th, which is looking cells in column "J"
with all start of "HG", anybody can help please?

Sub Macro1()
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "I") = "" Or Cells(i, "J") = "sss" Or Cells(i, "J") =
"ccccc" Or Cells(i, "J") = "//" Or Cells(i, "J") = "HG*" Then
Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub


Rick Rothstein

Delete row problem
 
UCase(Cells(i, "J")) Like "HG*" Then

Or, alternately, use this Like operator pattern method...

Cells(i, "J") Like "[Hh][Gg]*" Then

--
Rick (MVP - Excel)


"OssieMac" wrote in message
...

Change = to Like if using wild cards.

Cells(i, "J") Like "HG*" Then

Also note that due to case sensitive in the comparison with = etc you
might
have to convert the value to uppercase or lower case for the purpose of
the
comparison like the following.

UCase(Cells(i, "J")) Like "HG*" Then


--
Regards,

OssieMac


"Seeker" wrote:

First 3 criteria work but not the 4th, which is looking cells in column
"J"
with all start of "HG", anybody can help please?

Sub Macro1()
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "I") = "" Or Cells(i, "J") = "sss" Or Cells(i, "J") =
"ccccc" Or Cells(i, "J") = "//" Or Cells(i, "J") = "HG*" Then
Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub



Seeker

Delete row problem
 
Tks vm Qssie, it works.

"OssieMac" wrote:


Change = to Like if using wild cards.

Cells(i, "J") Like "HG*" Then

Also note that due to case sensitive in the comparison with = etc you might
have to convert the value to uppercase or lower case for the purpose of the
comparison like the following.

UCase(Cells(i, "J")) Like "HG*" Then


--
Regards,

OssieMac


"Seeker" wrote:

First 3 criteria work but not the 4th, which is looking cells in column "J"
with all start of "HG", anybody can help please?

Sub Macro1()
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "I") = "" Or Cells(i, "J") = "sss" Or Cells(i, "J") =
"ccccc" Or Cells(i, "J") = "//" Or Cells(i, "J") = "HG*" Then
Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub



All times are GMT +1. The time now is 10:48 PM.

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