Netwrkengeer
IS-IT--Management
I need a macro that will delete all data except email addresses, the data may be a cell full of text then an email address in the middle of the text. this is what I have... The problem with this macro is it deletes the columns and I need it to delete all data, other then the email address, Also I would like it to delete duplicate email addresses.
[ Sub ExtractAddresses()
Application.ScreenUpdating = False
Range("A65536"
.Select
ActiveCell.End(xlUp).Select
x = ActiveCell.Offset(1, 0).Address
intCounter = 1
Range("B1"
.Select
Columns("A:A"
.Select
Selection.Find(What:="Contact: E-mail ", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
x = ActiveCell.Address
ActiveCell.Offset(0, 1).Value = "%"
x = ActiveCell.Address
Selection.FindNext(After:=ActiveCell).Activate
Do Until ActiveCell.Address = x
ActiveCell.Offset(0, 1).Value = "%"
Selection.FindNext(After:=ActiveCell).Activate
intCounter = intCounter + 1
Loop
Range("B1"
.Select
Do Until intCounter = 0
If ActiveCell.Value <> "%" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
intCounter = intCounter - 1
End If
Loop
Columns("B:B"
.Select
Selection.Delete
Range("A1"
.Select
End Sub ]
Thanks
[ Sub ExtractAddresses()
Application.ScreenUpdating = False
Range("A65536"
ActiveCell.End(xlUp).Select
x = ActiveCell.Offset(1, 0).Address
intCounter = 1
Range("B1"
Columns("A:A"
Selection.Find(What:="Contact: E-mail ", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
x = ActiveCell.Address
ActiveCell.Offset(0, 1).Value = "%"
x = ActiveCell.Address
Selection.FindNext(After:=ActiveCell).Activate
Do Until ActiveCell.Address = x
ActiveCell.Offset(0, 1).Value = "%"
Selection.FindNext(After:=ActiveCell).Activate
intCounter = intCounter + 1
Loop
Range("B1"
Do Until intCounter = 0
If ActiveCell.Value <> "%" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
intCounter = intCounter - 1
End If
Loop
Columns("B:B"
Selection.Delete
Range("A1"
End Sub ]
Thanks