Convert dumb customer records to csv for database import

y2gabs

New Member
Joined
Mar 24, 2006
Messages
15
Hey guys,

I know this question is likely answered somewhere here, or at least addressed... I've tried searching for any words I can think of that might relate to the question but no luck. Regardless, please see below:

Column1 Column2
Business Name Company X
Address Address XXX; city; province
Phone 1 XXX-XXX-XXXX
Fax XXX-XXX-XXXX
Email email@company.com
Website www.website.com

Business Name Company Y
Address Address XXX; city; province
Phone 1 XXX-XXX-XXXX
Fax XXX-XXX-XXXX
Email email@company.com
Website www.website.com

See file here:
http://www.rawkmedia.com/Customer-Sample.xls

My question is, is there an easy way or macro out there to convert the above records (1000's), that were kept in such a stupid format for years, into the proper format (each column representing Business Name, Address, Phone, etc) for importing into a database?

Does my question make sense?

Anyway, any help would be HUGE!

Thanks!!

J.
 
Last edited:

djreiswig

Well-known Member
Joined
Mar 13, 2010
Messages
523
Your title was a little confusing with CSV. I'm assuming you want the data organized into columns in an Excel sheet. If you truly want a Comma Separated Values file, then this won't do that.

If you want it organized by columns then try this:

Add a new sheet and rename it Customer-New

Make sure the data you have looks exactly like the sample you provided.
With the customer data in column C starting at row 2 and a blank line between every customer's data

Paste this into a module and run it.

I'm sure this isn't the most elegant solution, but I think it should do what you want.

Code:
Sub OriganizeCustomers()

'make headers
For h = 1 To 6
    Sheets("Customer-New").Range(Choose(h, "A", "B", "C", "D", "E", "F") & "1").Value = _
    Sheets("Customer-Sample").Range("B" & h + 1).Value
Next h

'next row in new sheet
'first row is headers
newrow = 2
'next coumn in new sheet
newcolumn = 1

'loop through all data in column "C" in old sheet
For i = 2 To Sheets("Customer-Sample").Range("C" & Rows.Count).End(xlUp).Row
    
    'transfer data
    Sheets("Customer-New").Range(Choose(newcolumn, "A", "B", "C", "D", "E", "F") & newrow).Value = _
    Sheets("Customer-Sample").Range("C" & i).Value
    
    'go to next column in new sheet
    newcolumn = newcolumn + 1
    
    'each customer has 6 data items so
    'skip 1 row in old sheet if next row is multiple of 7
    If i Mod 7 = 0 Then
        i = i + 1
        'next customer so go to next row and back to first column in new sheet
        newrow = newrow + 1
        newcolumn = 1
    End If
Next i
    
End Sub
 

Forum statistics

Threads
1,081,835
Messages
5,361,600
Members
400,640
Latest member
fruitbros

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top