Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default MS Excel Delete row if criteria is meet

I have a table in the worksheet 'Central'.
This table currently occupies cells B7 to G1000.
The length of the table may vary. So G10001 or more rows.
The data found on first column of the table on column B7 to B????,
there are a series of 'YES' or 'NO' or other text on each cell going
down.

Is it possible for a macro to go through each cell in column B7 to
B???? in the table and delete the entire record row if the criteria
text 'NO' is identified in the cell and remove the formatting and
colors for the other rows which does not have 'NO' as a text.

Can this be done by VBA and without the excel filters?

Appreicate you help in advance...


Many thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default MS Excel Delete row if criteria is meet

Hi,

This goes in a general module and works on the active sheet. You will need
to add to the formatting conditions to remove others I never included.

Sub delete_Me2()
Dim copyrange As Range
lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set MyRange = Range("B7:B" & lastrow)
For Each c In MyRange
If UCase(c.Value) = "NO" Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If
End If
If UCase(c.Value) = "YES" Then
With c.EntireRow.Interior
.Pattern = xlNone
End With

With c.EntireRow.Font
.Name = "Arial"
.Size = 11
End With
End If
Next
If Not copyrange Is Nothing Then
copyrange.Delete
End If
End Sub


Mike

"How Two" wrote:

I have a table in the worksheet 'Central'.
This table currently occupies cells B7 to G1000.
The length of the table may vary. So G10001 or more rows.
The data found on first column of the table on column B7 to B????,
there are a series of 'YES' or 'NO' or other text on each cell going
down.

Is it possible for a macro to go through each cell in column B7 to
B???? in the table and delete the entire record row if the criteria
text 'NO' is identified in the cell and remove the formatting and
colors for the other rows which does not have 'NO' as a text.

Can this be done by VBA and without the excel filters?

Appreicate you help in advance...


Many thanks.

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 data in cells that don't meet criteria SITCFanTN New Users to Excel 1 June 10th 06 09:03 PM
Delete rows that do not meet specific criteria SITCFanTN Excel Programming 3 June 6th 06 04:36 PM
Delete Rows where cells does not meet criteria Danny Excel Worksheet Functions 1 September 12th 05 05:08 PM
how do i delete rows when cells meet certain criteria? Tbal[_4_] Excel Programming 1 August 15th 05 05:19 PM
Excel 2000 VBA - Delete Rows That Meet Criteria William Horton[_2_] Excel Programming 5 May 16th 05 07:51 PM


All times are GMT +1. The time now is 12:39 AM.

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"