Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete an entire row if a selected row doesn't have a specified value in a cell

I am looking to delete an entire row if it doesn't have a cell with
certain criteria in it... for example in a cell the value would be in
a column: placed on hold
How could I create a macro that would delete every row that did not
have this value in it?
Thanks!

-Marcus

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete an entire row if a selected row doesn't have a specified value in a cell

Hi Marcus

Try this one for the activesheet
If the vale "ron" not exist it delete the row

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If Application.WorksheetFunction.CountIf(.Rows(Lrow), "ron") = 0 Then .Rows(Lrow).Delete
' Delete each row if the value "Ron" not exist in the row (It will look in the whole row)

Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


See also
http://www.rondebruin.nl/delete.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ups.com...
I am looking to delete an entire row if it doesn't have a cell with
certain criteria in it... for example in a cell the value would be in
a column: placed on hold
How could I create a macro that would delete every row that did not
have this value in it?
Thanks!

-Marcus

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
Specify a row based on data from a cell to delete entire row..... Fadedmartinikiss Excel Discussion (Misc queries) 0 March 11th 09 08:39 PM
if a cell equal to zero how can it delete entire row yehia Excel Programming 1 June 17th 07 12:05 PM
Delete entire row based on cell color CMcK Excel Programming 3 October 27th 06 02:00 PM
Highlight the entire row of a selected cell Kerrick Sawyers Excel Programming 1 February 25th 04 06:49 PM
Delete entire row based on cell content PHIL Excel Programming 2 December 3rd 03 01:39 AM


All times are GMT +1. The time now is 04:04 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"