Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Delete Rows based on cell values.

I am trying to expand on my simple macro to:

Look in column B and if it finds the value "No Employee" to select
that row and delete it. I also would like look in column C for values
that are 500 or less and delete that row.

My data could be as little as 75 rows to several hundred rows. And
these values could appear several times in there respective columns.
I'm not sure how to get the code to delete multiple instances.


Sub RemoveEmployee()
If Range("B5").Value = "No Employee" Then

Rows("5:5").Select
Selection.Delete Shift:=xlUp
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Delete Rows based on cell values.

This will start at the last row containing data in column B and run
backwards to row #2. At anytime during the cycle, if column B of the
row = "No Employee" or column C of the row is less than or equal to
500, the row will be deleted.
Sub RemoveEmployee()
Dim r As Long
For r = Cells(Rows.Count, 2).End(xlUp).Row To 2 Step -1
If Cells(r, 2).Text = "No Employee" Or _
Cells(r, 3).Value <= 500 Then Rows(r).EntireRow.Delete
Next r
End Sub
Little Penny wrote:
I am trying to expand on my simple macro to:

Look in column B and if it finds the value "No Employee" to select
that row and delete it. I also would like look in column C for values
that are 500 or less and delete that row.

My data could be as little as 75 rows to several hundred rows. And
these values could appear several times in there respective columns.
I'm not sure how to get the code to delete multiple instances.


Sub RemoveEmployee()
If Range("B5").Value = "No Employee" Then

Rows("5:5").Select
Selection.Delete Shift:=xlUp
End If
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
How do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
Deleting rows based on values in a a cell in the row Martin New Users to Excel 1 January 25th 09 11:46 AM
Delete duplicate rows based on part of cell. okrob Excel Programming 0 February 14th 07 07:25 PM
Delete rows based on Cell name gmunro Excel Programming 1 November 25th 05 01:09 PM
Hide/Delete entire rows based in the content of one cell Clueless Excel Discussion (Misc queries) 2 October 3rd 05 02:40 PM


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