Extract Address and phone numbers from raw data.

donlincolnmre2

Board Regular
Joined
Dec 23, 2006
Messages
142
Hello

I have a spread sheet with bunch of raw data and its all in colum A, within that data there are 4 fields, Name, address, city state zip, phone number, I'm looking to extract that information from column A in to column, b, c, d, e, the macro suppose to grab that text from those 4 rows and just make 1 row, and placed that data in Column B, C, D and E, the macro should search for the entire sheet for those records.

Thanks.


here is the data.


Oklahoma l
Oregon l
Pennsylvania l
Rhode Island l
South Carolina l
South Dakota l
Tennessee l
Texas l
Utah l
Vermont l
Virginia l
Washington l
West Virginia l
Wisconsin l
Wyoming l
Lint, Michael G
2917 Ninth Ave
Sacramento, CA 95818-4046
(916) 446-4218
Find Neighbors l
Map and Driving Directions l
Printer-Friendly l
Send Listing to my Email l
Find Nearby Businesses l
Type: Land Line
SPONSORED LINKS
Listing date Nov. 2009
Local Information for Sacramento, CA
Population: 407,018 l
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
donlincolnmre2,

Can we see another 30 to 50 rows of your raw data?



The macro should only extract the data, if there is a phone number in column A

Here is the rest of the data

Arizona l
Arkansas l
California l
Colorado l
Connecticut l
Delaware l
District Of Columbia l
Florida l
Georgia l
Select -ഊHawaii l
Idaho l
Illinois l
Indiana l
Iowa l
Kansas l
Kentucky l
Louisiana l
Maine l
Maryland l
Massachusetts l
Michigan l
Minnesota l
List ViewMap View
Display: All (6) Home (5) Work (1)
Sort by:
Garroutte, Verdell
2529 S Coast Hwy, Apt E
Laguna Beach, CA 92651-3961
(949) 715-0922
Listing Detail
SPONSORED LINKS
Wilson, Rodney
2529 S Coast Hwy
Laguna Beach, CA 92651-3961
(949) 494-6939
Listing Detail
SPONSORED LINKS
Bottjer, Sherill L
2529 S Coast Hwy, Apt G
Laguna Beach, CA 92651-3961
(949) 494-6807
Listing Detail
SPONSORED LINKS
Gentry, Steve
Job title:
Owner
Company:
Gentry Plumbing
2529 S Coast Hwy
Laguna Beach, CA 92651-3961
Listing Detail
SPONSORED LINKS
Jones, Jerrod W
2529 S Coast Hwy, Apt G
Laguna Beach, CA 92651-3961
(949) 494-6807
Listing Detail
SPONSORED LINKS
Jones, Roger W
2529 S Coast Hwy, Apt G
Laguna Beach, CA 92651-3961
(949) 494-6807
Listing Detail
SPONSORED LINKS
Display: All (6) Home (5) Work (1)
Sort by:
Printer-Friendly Page
Phone Directory l
People Search l
Business Search l
Reverse Phone l
Reverse Address l
Area and ZIP Codes l
Site Sections
Telephone Directory
People Phone Number Search
Business Phone Number Search
Reverse Phone Directory
Reverse Address Finder
Area Code and ZIP Code Finder
Site Map
Regional Information
Phone Book by City and State
Phone Service by City and State
More Information
Reverse Phone Book
Search by Phone Number Lookups
Phone Service
Phone Listing
Online Phone Book
Privacy Central
Contact Us
Phone Books by State
Alabama l
Alaska l
Arizona l
Arkansas l
California l
Colorado l
Connecticut l
Delaware l
District Of Columbia l
Florida l
Georgia l
Select -ഊHawaii l
Idaho l
Illinois l
Indiana l
Iowa l
Kansas l
Kentucky l
Louisiana l
Maine l
Maryland l
Massachusetts l
Michigan l
Minnesota l
Mississippi l
Missouri l
Montana l
Nebraska l
Nevada l
New Hampshire l
New Jersey l
New Mexico l
New York l
North Carolina l
North Dakota l
Ohio l
Oklahoma l
Oregon l
Pennsylvania l
Rhode Island l
South Carolina l
South Dakota l
Tennessee l
Texas l
Utah l
Vermont l
Virginia l
Washington l
West Virginia l
Wisconsin l
Wyoming l
Phone Service by State
Alabama l
Alaska l
Arizona l
Arkansas l
California l
Colorado l
Connecticut l
Delaware l
District Of Columbia l
Florida l
Georgia l
Hawaii l
Idaho l
Illinois l
Indiana l
Iowa l
Kansas l
Kentucky l
Louisiana l
Maine l
Maryland l
Massachusetts l
Michigan l
Minnesota l
Mississippi l
Missouri l
Montana l
Nebraska l
Nevada l
New Hampshire l
New Jersey l
New Mexico l
New York l
North Carolina l
North Dakota l
Ohio l
Oklahoma l
Oregon l
Pennsylvania l
Rhode Island l
South Carolina l
South Dakota l
Tennessee l
 
Upvote 0
donlincolnmre2,

With all of your two posted data examples beginning in cell A1, before the macro:


Excel Workbook
ABCDE
1Oklahoma l
2Oregon l
3Pennsylvania l
4Rhode Island l
5South Carolina l
6South Dakota l
7Tennessee l
8Texas l
Sheet1





After the macro:


Excel Workbook
ABCDE
1Oklahoma lLint, Michael G2917 Ninth AveSacramento, CA 95818-4046(916) 446-4218
2Oregon lGarroutte, Verdell2529 S Coast Hwy, Apt ELaguna Beach, CA 92651-3961(949) 715-0922
3Pennsylvania lWilson, Rodney2529 S Coast HwyLaguna Beach, CA 92651-3961(949) 494-6939
4Rhode Island lBottjer, Sherill L2529 S Coast Hwy, Apt GLaguna Beach, CA 92651-3961(949) 494-6807
5South Carolina lJones, Jerrod W2529 S Coast Hwy, Apt GLaguna Beach, CA 92651-3961(949) 494-6807
6South Dakota lJones, Roger W2529 S Coast Hwy, Apt GLaguna Beach, CA 92651-3961(949) 494-6807
7Tennessee l
8Texas l
Sheet1





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub GetData()
' hiker95, 02/14/2010
Dim c As Range, firstaddress As String, NR As Long
Application.ScreenUpdating = False
With ActiveSheet
  .Range("A1").EntireRow.Insert
  If .Cells(2, 2) = "" Then
    NR = 2
  Else
    NR = .Range("B" & Rows.Count).End(xlUp).Offset(1).Row
  End If
  With .Columns(1)
    Set c = .Find("(*", LookIn:=xlValues, LookAt:=xlWhole)
    If Not c Is Nothing Then
      firstaddress = c.Address
      Do
        .Cells(NR, 2) = c.Offset(-3, 0)
        .Cells(NR, 3) = c.Offset(-2, 0)
        .Cells(NR, 4) = c.Offset(-1, 0)
        .Cells(NR, 5) = c
        NR = .Range("B" & Rows.Count).End(xlUp).Offset(1).Row
        Set c = .FindNext(c)
      Loop While Not c Is Nothing And c.Address <> firstaddress
    End If
  End With
  .Range("A1").EntireRow.Delete
  .Range("B1:E" & Cells(Rows.Count, 1).End(xlUp).Row).Columns.AutoFit
End With
Application.ScreenUpdating = True
End Sub


Then run the "GetData" macro".
 
Upvote 0

Forum statistics

Threads
1,215,447
Messages
6,124,906
Members
449,194
Latest member
JayEggleton

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