PDA

View Full Version : WRITING A VBA CODE



michaelja
11-01-2008, 10:04 AM
I need to write a VBA code for the following

Jeff & Susan Smith
115 North Lakeridge Parkway, Suite 100
Ashland, VA 23005
Randal & Kathy Smith
1070 Oakway Court
Richmond, VA 23233

Theres about 170 pages of these entries on Microsoft Word and Im trying to convert them all into a spreadsheet that is seperated by columns by Name/ Address/ City,St/ Children/ Phone number.

How do I write a code to seperate all of these listings into different columns??

Thanks, Jamie

mdmackillop
11-01-2008, 01:42 PM
Hi Jamie
Welcome to VBAX
You can separate by line, punctuation (comma etc.) , formatting (Bold) and numeric values. Beyond this, you need some logic which I can't see here.

rbrhodes
11-01-2008, 05:11 PM
Hi Jamie,

If all that's in the Word file are addresses then try this:

-Save this Excel file in a directory of your choice

-Save the Word file as a Text file eg "Jeff.txt" in the same directory

-Open Addresses.xls in Excel

-Click the 'Do Address' button.

What it does:

- Opens and imports the text file name you input

- Searches each line for a Zip Code (min 5 digits)

- Transposes what it finds based on the Zip Code

- Deletes the originals from Col A

- Autofits whats left

What it doesn't do:

- Save any files

- Handle errors

- Make coffee

rbrhodes
11-01-2008, 05:18 PM
Hi Jamie,

Just read you question again. Your examples do not match what you describe!

Are all of the records 5 lines long:

Name
Address
City,St
Children
Phone number

The posted code works on your _examples_, and although it checkd for variable nuber of rows in the addresses, it won't work on your description...:banghead: