Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus batch bios bsod crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Delete rows when specific words are found

Reply  
Thread Tools
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
26-Jul-2010, 11:25 PM #1
Question Solved: Delete rows when specific words are found
Hi,

I have a worksheet that contains 2 columns of data. I have listed a sample of the data as below column A and column B

...............Column A....................................Column B
Row 1......blacktalldog.com..........................black tall dog
Row 2......blackhungrymouse.com................black hungry mouse
Row 3......thebigshortdog.net........................the big short dog
Row 4......bigblacktable.net..........................big black table
Row 5......bigtalltree.net...............................big tall tree

I have some questions on how to do the things I want.

1) I want to excel to search the whole document and detect rows with cells that start with the word 'black' and cells that start with the word 'big'. Delete the whole rows.

results to return will be
Row 3......thebigshortdog.net........................the big short dog

2) I want to search Column A only, delete the rows if the cells in Column A ends with '.net'

results to return will be
Row 1......blacktalldog.com..........................black tall dog
Row 2......blackhungrymouse.com................black hungry mouse

3) I want to detect cells that contain the word tall. If the word tall is detected in Column A or Column B, delete the row.

results to return will be
Row 2......blackhungrymouse.com................black hungry mouse
Row 3......thebigshortdog.net........................the big short dog
Row 4......bigblacktable.net..........................big black table


Thanks
etaf's Avatar
Computer Specs
Moderator with 34,408 posts.
 
Join Date: Oct 2003
Location: Surrey, UK
Experience: Intermediate
27-Jul-2010, 05:34 AM #2
will this be something you want to be able to do over again or a one off exercise ?

if once only - you could put a flag into column C and then sort by column c and delete

this ishow I would do it - BUT there maybe a much simpler way
so in C I would use something like OR to test cell A and B
OR(mid(a2,1,5)="black",mid(a2,1,3="big", mid(b2,1,5)="black",mid(b2,1,3)="big)
That will test for the first condition
you can use the same idea for the .net and an IF around the lot to set the flag

If this is a oneoff upload a small sample excel spreadsheet and I can code for you - if a regular requirement then I suspect VBA would be better
__________________
Note: I have very limited time during weekdays to visit here, so there will be a delay in replying
UK timezone
Please let us know what the final solution was to any problem posted
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
27-Jul-2010, 06:02 AM #3
Thanks for the reply

I need to do this over again many times. Is there other solutions?

Although I need to do this over again, I am wonder how do I apply what you have written

"this ishow I would do it - BUT there maybe a much simpler way
so in C I would use something like OR to test cell A and B
OR(mid(a2,1,5)="black",mid(a2,1,3="big", mid(b2,1,5)="black",mid(b2,1,3)="big)
That will test for the first condition
you can use the same idea for the .net and an IF around the lot to set the flag"
etaf's Avatar
Computer Specs
Moderator with 34,408 posts.
 
Join Date: Oct 2003
Location: Surrey, UK
Experience: Intermediate
27-Jul-2010, 06:58 AM #4
so breaking my idea down bit by bit - its not the best way to do this i'm sure one of the gurus will provide a simpler method
anyway
NOTE - This is all case sensitive as well - so would need to add something like upper to account for case too
for your 1st condition
=IF(OR(MID(A2,1,5)="black",MID(B2,1,5)="black",MID(A2,1,3)="big",MID(B2,1,3 )="big"),1,0)
for your 2nd condition
=IF((MID(A2,LEN(A2)-3,4)=".net"),1,0)
for your 3rd condition
=IF(ISERROR(FIND("tall",A2,1)),IF(ISERROR(FIND("tall",B2,1)),0,1),1)
and then to do all conditions in one go
=IF(OR(MID(A2,1,5)="black",MID(B2,1,5)="black",MID(A2,1,3)="big",MID(B2,1,3 )="big",MID(A2,LEN(A2)-3,4)=".net"),1,IF(ISERROR(FIND("tall",A2,1)),IF(ISERROR(FIND("tall",B2,1)), 0,1),1))

I have attached a sample spreadsheet
Attached Files
File Type: xls big-black-etaf.xls (21.0 KB, 30 views)
__________________
Note: I have very limited time during weekdays to visit here, so there will be a delay in replying
UK timezone
Please let us know what the final solution was to any problem posted
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
27-Jul-2010, 08:23 AM #5
Thanks for the help, I appreciate it.

Ok. I get what you mean, from your sample spreadsheet, I will need to manually spot those rows that contains the 1 and delete it. This is suitable for one time use and small sample. My worksheet is large and I need to do this frequently. I think there will be other methods that is simpler.
etaf's Avatar
Computer Specs
Moderator with 34,408 posts.
 
Join Date: Oct 2003
Location: Surrey, UK
Experience: Intermediate
27-Jul-2010, 08:27 AM #6
yep, i agree - you can sort the spreadsheet by the 1's and it will be easy to then delete/spot the rows

to help a VBA expert - do you need to have the rows deleted seperately depending on the conditions
IE
Only delete if black and big appears
then a separate condition to only delete the .net
then a separate condition to delete the tall

OR

do you apply for all the conditions and delete everything
so black, big, tall, .net all the rows deleted as per your conditions that apply
__________________
Note: I have very limited time during weekdays to visit here, so there will be a delay in replying
UK timezone
Please let us know what the final solution was to any problem posted
Keebellah's Avatar
Computer Specs
Senior Member with 3,541 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
27-Jul-2010, 08:37 AM #7
I would suggest VBA code (macro's) and based upon a list in a separate tab (sheet) you could easily make it dynamic, the formula's as now used are very static and new values require quite a lot of changes.
If Skytech answers Etaf's last question then we could work on it and attach a sample to see if this would be what is asked for.
__________________
Cheers,
Hans
It's all in the code... and may the code be with you! If it isn't . . . start debugging! (Time zone: Western Europe)
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
27-Jul-2010, 09:52 AM #8
I can apply for all conditions and deleted it at once, but I need to access the code to make little changes by myself in future, for example, maybe next time I want to detect the word blue, small, or other words.

I have redo a newsample. I have attached the sample.

newsample
...............Column A....................................Column B
Row 1......blacktalldog.com..........................black tall dog
Row 2......blackhungrymouse.com..................black hungry mouse
Row 3......thebigshortdog.net.......................the big short dog
Row 4......bigblacktable.net..........................big black table
Row 5......bigtalltree.net..............................big tall tree
Row 6......myrowsixbigcats.com.....................my row six big cats
Row 7......bluetallhouseseven.net...................blue tall house seven
Row 8......eighttalltables.com........................eight tall tables
Row 9......blackninecats.com.........................black nine cats
Row 10.....tenbigdogs.org.............................ten big dogs
Row 11.....elevengooddays.com.....................eleven good days
Row 12.....twelvesleepydays.org....................twelve sleepy days
Row 13.....thirteennicetables.com..................thirteen nice tables
Row 14.....fourteendayssmallcats.com............fourteen days small cats
Row 15.....fifteendaysblackcats.com..............fifteen days black cats

I have simplified my questions criteria as below,

1) search the whole document and detect rows with cells that start with the word 'black' and cells that start with the word 'big'. Delete the whole row.

2) I want to search Column A, delete the rows if the cells in Column A ends with '.net'

3) I want to detect cells that contain the word tall. If the word tall is detected anywhere in Column A or Column B, delete the row.

4) I want to detect cells that end with 'days' and delete the rows. (in this case, I think Column B is necessary? or is there a way to do it with just column A?)


My end result should be
Row 6.......myrowsixbigcats.com...............my row six big cats
Row 10......tenbigdogs.org.......................ten big dogs
Row 13......thirteennicetables.com............thirteen nice tables
Row 14......fourteendayssmallcats.com.......fourteen days small cats
Row 15......fifteendaysblackcats.com.........fifteen days black cats
Attached Files
File Type: xls newsample.xls (17.0 KB, 35 views)
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
27-Jul-2010, 03:19 PM #9
VBA gurus, perhaps a message box popping up that would then allow for the user to input what is to be looked for (and then deleted)?
Keebellah's Avatar
Computer Specs
Senior Member with 3,541 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
27-Jul-2010, 03:31 PM #10
I think this is a good idea, you can always have alist availiable as default and if necessary have prompt for a value.
Keebellah's Avatar
Computer Specs
Senior Member with 3,541 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
27-Jul-2010, 04:58 PM #11
I have attached the sample Etaf had used with some extra info.

Try and see if this is another option
Attached Files
File Type: xls skytech-big-black-etaf.xls (26.5 KB, 35 views)
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
28-Jul-2010, 01:10 AM #12
Yes, if someone can make a message box popping or something for me to input the words that I want to filter out, that would be great. I got a minor change, instead of deleting the rows, if the criteria for the words are found, just fill the rows with grey and arrange all the grey rows to the bottom of the data (so I will see the data I want on top, and bottom of the worksheet are the greyed rows are the data that I do not want)

Keebellah, thanks for the extra info, but that is not exactly I want. It is good for a small sample, but in my real data, my worksheet have thousands of rows and I need to filter out many words. Other that filtering out words that start with 'black', 'big', I still have many other words that I want to filter out.
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
28-Jul-2010, 01:58 AM #13
what about if the text begins with, say, "big" but it isn't really the word "big" like in "bigtalltree.net" but is "bigotagainstcats.net"? A LEFT() search will pick both out as items to be greyed out and moved.
Unless this is a sample of, like, chemical formulas, that you want to clean up, you will have this problem. And if it is something like that, tell us.
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.
My theme song... | Affero - rate me!
skytech's Avatar
Computer Specs
Member with 60 posts.
 
Join Date: Nov 2009
Experience: Intermediate
28-Jul-2010, 02:18 AM #14
Quote:
Originally Posted by slurpee55 View Post
what about if the text begins with, say, "big" but it isn't really the word "big" like in "bigtalltree.net" but is "bigotagainstcats.net"? A LEFT() search will pick both out as items to be greyed out and moved.
Unless this is a sample of, like, chemical formulas, that you want to clean up, you will have this problem. And if it is something like that, tell us.
Yes, as long as the text begins with the word 'big' is detected, all the items will be that start with the word 'big' will be greyed. I want to detect all. So in your example, "bigtalltree.net" and "bigotagainstcats.net" will be greyed out.

In my sample you see Row 4 bigblacktable.net and Row 5 bigtalltree.net are the rows that begins with the word big, so both rows should be detected and greyed out.
Keebellah's Avatar
Computer Specs
Senior Member with 3,541 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Never too old to learn!
28-Jul-2010, 04:42 AM #15
I don't know what you will need it to do but the sample I sent you makes it 'elastic'
I'll edit it and send you a new sample to prove my point.
A prompt could be handy but entering your data in the first row and a formula that checks it and greys it our would be handy I think.

Will the list only contain two columns or is this a part of a more extended worksheet?
Contrary to .net will you search only on tekst strings at the begening?

What if mybigtalldog: no big no tall but doie it have to be greyed out?
__________________
Cheers,
Hans
It's all in the code... and may the code be with you! If it isn't . . . start debugging! (Time zone: Western Europe)
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
Excel VBA Macro to delete rows/columns with criteria anamque Business Applications 1 15-Jul-2010 04:59 AM
Excel 07 MACRO to delete rows/columns w/ criteria anamque Business Applications 1 14-Jul-2010 04:47 PM
delete rows not matching multiple criteria jsimms001 Business Applications 13 16-Oct-2008 03:31 PM
Solved: Macro that finds and highlights specific words in MS Word document enars Business Applications 5 11-Jul-2008 12:30 PM
using spamassassin to delete mail with specific word in the subject csross Web & Email 0 17-Feb-2005 01:57 PM


Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:44 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.