1. In your workbook, create a sheet called WebMD, and add your column headings.
2. Insert a code module and paste the code below into it.
3. On the Developer tab, click Macros, select PasteWebMD, and click Options.
4. For the Shortcut key, enter p (for Paste), and click Ok and Cancel.
5. Save the workbook as a .xlsm (macro-enabled)
The above is one-time only and sets up the functionality. Then ...
1. On the web page, go to the 1st page.
2. Press Ctrl-A (Select All) and Ctrl-C (Copy).
3. Flip over to the WebMD workbook and press Ctrl-P.
4. Go back to the browser, select the next page, and repeat steps 2 & 3.
5. Continue until you have all the pages.
To avoid needing the mouse, use Alt-Tab to flip back & forth.
You may need to make adjustments if you come across odd names or other issues, but this worked for the 1st 5 pages or so.
Maybe there's a better way to grab a full table out of a web site, but this is the only way I know how to do it.
Option Explicit
Dim PRow As Long, EndRow As Long, MDRow As Long, Txt As String, Pos As Long
Sub PasteWebMD()
Application.ScreenUpdating = False
Sheets.Add
ActiveSheet.Paste
On Error Resume Next
Cells.Find(what:="Showing ").Select
On Error GoTo 0
If ActiveCell.Address = "$A$1" Then
MsgBox """Showing"" text not found."
Exit Sub
End If
PRow = ActiveCell.Row + 2
EndRow = Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("WebMD")
MDRow = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
Do Until PRow > EndRow Or IsNumeric(Cells(PRow, 1).Value)
Txt = Cells(PRow, 1).Value
Pos = InStr(Txt, ",")
If Pos > 0 Then
.Cells(MDRow, 3).Value = Right(Txt, Len(Txt) - Pos) ' Type
Txt = Left(Txt, Pos - 1)
End If
Pos = InStr(Txt, ".")
If Pos = 0 Then
Pos = InStr(Txt, " ")
End If
.Cells(MDRow, 1).Value = Right(Txt, Len(Txt) - Pos) ' Last Name
.Cells(MDRow, 2).Value = Left(Txt, Pos - 1) ' 1st Name
.Cells(MDRow, 4).Value = Cells(PRow + 4, 1).Value ' Address
Txt = Cells(PRow + 5, 1).Value
.Cells(MDRow, 5).Value = Txt ' City, St, Zip
Pos = InStrRev(Txt, " ")
.Cells(MDRow, 6).Value = Right(Txt, Len(Txt) - Pos) ' Zip
MDRow = MDRow + 1
PRow = Cells(PRow + 5, 1).End(xlDown).Row ' Experience/Location section
If Cells(PRow + 1, 1).Value <> "" Then
PRow = Cells(PRow, 1).End(xlDown).Row
End If
PRow = Cells(PRow, 1).End(xlDown).Row ' Next Name
Loop
.Columns("A:F").AutoFit
End With
Application.DisplayAlerts = False
ActiveSheet.Delete
End Sub
Bookmarks