Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Picture VBA If Then Problem Shawn Excel Programming 1 August 21st 06 09:37 PM
Delete row problem, could some help me on that? ina Excel Programming 5 June 8th 06 07:00 PM
Delete problem Loi New Users to Excel 3 December 8th 04 01:35 AM
Delete Sheets Problem Edgar Thoemmes[_4_] Excel Programming 3 October 27th 04 12:32 PM
Name Delete Problem Again Meme Excel Programming 1 April 9th 04 03:31 AM


All times are GMT +1. The time now is 06:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"