PC Review


Reply
Thread Tools Rate Thread

Delete row problem

 
 
Seeker
Guest
Posts: n/a
 
      23rd Feb 2010
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 With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      23rd Feb 2010

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 With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      23rd Feb 2010
> 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" <(E-Mail Removed)> wrote in message
news:191E28C1-1E58-4D81-B596-(E-Mail Removed)...
>
> 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 With Quote
 
Seeker
Guest
Posts: n/a
 
      23rd Feb 2010
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot-Up Problem/Desk-Top Delete Problem =?Utf-8?B?RWQgRGVHYW5p?= Windows XP Accessibility 0 1st Jun 2007 06:30 AM
C# Delete Problem =?Utf-8?B?Q2hyaXM=?= Microsoft ADO .NET 1 9th Apr 2007 11:46 AM
fixed unable to delete email problem, now I have new problem =?Utf-8?B?ajI=?= Windows Vista Mail 19 30th Mar 2007 02:25 AM
new and delete problem =?Utf-8?B?QmVycnl3b25n?= Microsoft VC .NET 1 2nd May 2005 09:32 PM
Delete Row Problem Erica Microsoft ADO .NET 1 10th Jun 2004 12:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:08 PM.