Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Deleting rows based on values in a column

I forgot to add that I assumed that you have a heading in row 1 of column D that you want to keep.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Bob,

Without looping:

Sub Bob()
Range("D:D").AutoFilter Field:=1, _
Criteria1:="=Completed", Operator:=xlOr, _
Criteria2:="=Cancelled"
Range("D2:D65536").SpecialCells(xlCellTypeVisible) .EntireRow.Delete
Range("D:D").AutoFilter
End Sub

HTH,
Bernie
MS Excel MVP


"Bob" wrote in message
...
I'm trying to write a macro that I can embed within an existing subroutine
that will delete an entire row if the value in column D = "Completed" OR
"Cancelled". Although the number of rows in the worksheet can vary from day
to day (I download an updated worksheet from a system daily), I would prefer
to use a macro that does not utilize looping (if possible). Instead, I
already know the total number of rows containing data based on the following
two lines of code:

Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row

Any help would be greatly appreciated. Thanks.
Bob





  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Deleting rows based on values in a column

Bernie,
Your solution is excellent . . . and without looping! You assumed correctly
that row 1 has heading labels (I should have mentioned that). Thanks for all
your help! I greatly appreciate it.
Bob


"Bernie Deitrick" wrote:

I forgot to add that I assumed that you have a heading in row 1 of column D that you want to keep.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Bob,

Without looping:

Sub Bob()
Range("D:D").AutoFilter Field:=1, _
Criteria1:="=Completed", Operator:=xlOr, _
Criteria2:="=Cancelled"
Range("D2:D65536").SpecialCells(xlCellTypeVisible) .EntireRow.Delete
Range("D:D").AutoFilter
End Sub

HTH,
Bernie
MS Excel MVP


"Bob" wrote in message
...
I'm trying to write a macro that I can embed within an existing subroutine
that will delete an entire row if the value in column D = "Completed" OR
"Cancelled". Although the number of rows in the worksheet can vary from day
to day (I download an updated worksheet from a system daily), I would prefer
to use a macro that does not utilize looping (if possible). Instead, I
already know the total number of rows containing data based on the following
two lines of code:

Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row

Any help would be greatly appreciated. Thanks.
Bob






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
Deleting rows based on column values Dazed and Confused[_2_] New Users to Excel 3 February 6th 09 10:47 PM
Summing rows based on other column values jonny Excel Worksheet Functions 7 January 28th 09 11:45 PM
Deleting rows based on values in a a cell in the row Martin New Users to Excel 1 January 25th 09 11:46 AM
Deleting Rows based on Column Critieria blackmanofsteel40 Excel Discussion (Misc queries) 1 September 7th 07 09:05 PM
Deleting rows based upon the value in column D Sean Excel Programming 2 October 25th 04 08:59 PM


All times are GMT +1. The time now is 09:43 PM.

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

About Us

"It's about Microsoft Excel"