Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Query to delete rows or columns


date Done To Be Did
01/03/2008 80 90 Friend
02/03/2008 42 80 friend
02/03/2008 20 70 Boy
04/02/2008 89 90 Friend
05/02/2008 90 90 Boy

In the above, how can i write a simple formula or query to delete a row
whenever Boy is seen in a cell?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Query to delete rows or columns

With a macro

Right click the sheet tab, view code and paste this in and run it

Sub stance()
Dim myrange, copyrange As Range
Lastrow = Cells(Cells.Rows.Count, "D").End(xlUp).Row
Set myrange = Range("D2:D" & Lastrow)
For Each c In myrange
If UCase(c.Value) = "BOY" Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If
End If
Next
if not copyrange is nothing then
copyrange.Delete
end if

End Sub

Mike

"kilo" wrote:


date Done To Be Did
01/03/2008 80 90 Friend
02/03/2008 42 80 friend
02/03/2008 20 70 Boy
04/02/2008 89 90 Friend
05/02/2008 90 90 Boy

In the above, how can i write a simple formula or query to delete a row
whenever Boy is seen in a cell?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Query to delete rows or columns

I'd apply Data|Filter|Autofilter to the Did column.

Then filter to show the rows with Boy in that column.

Then delete the visible rows.

Then remove the filter (data|filter|autofilter) to see all the data again.

======
Another option would be to sort your data by that column so that the Boy's are
all grouped together and then just delete them manually. Since they're in a
single group, it should be pretty quick.

kilo wrote:

date Done To Be Did
01/03/2008 80 90 Friend
02/03/2008 42 80 friend
02/03/2008 20 70 Boy
04/02/2008 89 90 Friend
05/02/2008 90 90 Boy

In the above, how can i write a simple formula or query to delete a row
whenever Boy is seen in a cell?


--

Dave Peterson
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
Query doesn't add/delete data in rows on refresh boreal Excel Discussion (Misc queries) 2 October 12th 12 09:34 PM
Table rows & columns query UKdeejay Excel Discussion (Misc queries) 1 September 9th 07 06:42 AM
Delete rows that are empty across columns ALATL Excel Worksheet Functions 0 November 6th 06 04:09 AM
DELETE ROWS BY USING A IF/THEN QUERY CHARI Excel Worksheet Functions 2 June 1st 06 06:46 PM
Delete columns or rows Ivor Williams Excel Worksheet Functions 2 June 3rd 05 11:16 PM


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