Macro for extracting email from multiple URLs

riana

New Member
Joined
Nov 20, 2018
Messages
4
Hi all,

I have a list of websites in Excel, in column A1:A1100. I woul
d like a macro to find the email addresses on these websites, copy them, and paste them into B1:B1100. Is it possible?

Your help would be highly appreciated.
 
I didn't see any in my search (all @'s were mailto), though I didn't look at all.

Code:
Sub getemailfromwebsite()
Dim ie As internetExplorer
Dim url As String
Dim x As Long
Dim html As htmldocument
Dim ElementCol As Object
Set html = CreateObject("htmlfile")
Application.ScreenUpdating = False
Set ie = CreateObject("internetexplorer.application")
ie.Visible = False
x = 2
Do While Sheet1.Cells(x, 1) <> ""
url = Sheet1.Cells(x, 1)
'url = "http://www.easyexcelanswers.com/"
ie.navigate url
Do While ie.readystate <> readystate_complete
Application.StatusBar = "loading website..."
DoEvents
Loop
Set html = ie.document
Set ElementCol = html.getElementsByTagName("a")


For Each link In ElementCol
    If InStr(link, "@") Then
        Cells(x, 2).Value = link
        'Cells(x, 2) = Right(link, Len(link) - InStr(link, ":"))
         Cells(x, 2).Columns.AutoFit
    End If
Next
x = x + 1


Loop
Set ie = Nothing
Application.StatusBar = ""
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,216,733
Messages
6,132,415
Members
449,727
Latest member
Aby2024

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