MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 10th, 2002, 02:20 PM   #1
lkanarow@umich
New Member
 
Join Date: Mar 2002
Location: California
Posts: 6
Default

I have a massive excel file of about 300,000 e-mail addresses spread into 5 sheets. They are entries from contests and some of the e-mail addresses aren't really e-mail addresses. Is there a way for me to delete all cells in a column that DO NOT have the @ symbol?

If anyone knows a macro to this problem it would save me ALOT of time and tedious work, and it would be GREATLY appreciated.

thanks,
Lindsey
lkanarow@umich is offline   Reply With Quote
Old Apr 10th, 2002, 02:34 PM   #2
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,030
Default

Hiya,

Could you get away with auto-filters instead? -(I'm not sure if you're dealing with a lot more than 1 column per sheet)

In one column, for example, you can go to toolsautofilter then click on the arrowcustomcontains @ - then you could just copy the list of email addresses to another sheet. repeat per column.

Hope that helps somewhat
Adam
Asala42 is offline   Reply With Quote
Old Apr 10th, 2002, 02:37 PM   #3
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Try the following:

With ActiveSheet.UsedRange
Set c = .Find("@", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Font.ColorIndex = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

For Each cel In ActiveSheet.UsedRange
If cel.Font.ColorIndex <> 5 Then cel.ClearContents
Next cel

Always make a copy of your workbook before testing out macros.
__________________
Kind regards,

Al Chara
Al Chara is offline   Reply With Quote
Old Apr 10th, 2002, 02:43 PM   #4
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

How about this. It's not exactly refined but it works

Sub test()

'Assuming emails are all in Column A and Column B is blank
'Assume first row to look at is row 1
'(Adjust as you like)

Dim Lastrow As Integer


'Find end point
Lastrow = Range("A65536").End(xlUp).Row


'Fill in a formula down column B that tells us
'whether the value in A is valid or not (i.e. contains @)
Range("B1").FormulaR1C1 = "=IF(ISNUMBER(SEARCH(""@"",RC[-1])),1,0)"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B" & Lastrow)

'Remove unwanted cells
For i = 1 To Lastrow

Range("A" & i).Select
If ActiveCell.Offset(0, 1) = 0 Then
ActiveCell.ClearContents
End If
Next i

'Clear out Column B
Range("B1:B" & Lastrow).ClearContents

End Sub


Rgds
AJ
AJ is offline   Reply With Quote
Old Apr 10th, 2002, 02:44 PM   #5
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

Oops. Sorry Al, didn't realise you'd beaten me to it!
AJ is offline   Reply With Quote
Old Apr 10th, 2002, 04:37 PM   #6
lkanarow@umich
New Member
 
Join Date: Mar 2002
Location: California
Posts: 6
Default

Hey Al,

I've tried doing that as a macro in the vba, but I keep getting a compile error.

should I paste the whole thing in or only part of it.

sorry,I'm not to good with excel
lkanarow@umich is offline   Reply With Quote
Old Apr 10th, 2002, 04:57 PM   #7
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Sub YourMacroName()
'Paste code here
End Sub
__________________
Kind regards,

Al Chara
Al Chara is offline   Reply With Quote
Old Apr 10th, 2002, 06:11 PM   #8
lkanarow@umich
New Member
 
Join Date: Mar 2002
Location: California
Posts: 6
Default

hey Al,

I am trying the macro again, but it keeps coming up as an error on the second line .Find

Any suggestions?
lkanarow@umich is offline   Reply With Quote
Old Apr 11th, 2002, 08:04 AM   #9
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

lkanarow@umich,

I can't make my code not work. I don't know what you are doing wrong. What does your data look like, how is it arranged (all in one column, row)?
Al Chara is offline   Reply With Quote
Old Apr 11th, 2002, 08:47 AM   #10
sxpeter
New Member
 
Join Date: Apr 2002
Posts: 32
Default

This isn't as elegant as a macro, but you can enter the following formula in col B (assuming addresses are in col A) and copy down.

=IF(ISERR(SEARCH("@",A1)),"",SEARCH("@",A1))

It will return a number if @ is in the string and a blank if not. You can then sort by col B, which will put all blanks (non-email addresses)at the end, allowing you to easily delete those rows. Hope this is what you're looking for.

sxpeter
sxpeter is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes