Help...again. Need a macro to delete all cells without @ sy

lkanarow@umich

New Member
Joined
Mar 28, 2002
Messages
6
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
 
Hey Al,

Maybe I am doing something wrong. I copy and pasted your code into the Visual Basic Editor starting with "With ActiveSheet.UsedRange" through to "Next cel"

Then I tried to run the macro, but I keep getting a default. Am I not supposed to copy and paste all of that into the VBA? Do I need to name the macro or add Sub/ end sub?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
use the worksheet function method someone posted. then you won't have to mess around with the vb code.
 
Upvote 0
Yes you do have to put in between Sub and end sub:

Sub YourMacroName()
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
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top