+ Reply to Thread
Results 1 to 5 of 5

Convert 1 Dimension Data to 2 dimensions

  1. #1
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Convert 1 Dimension Data to 2 dimensions

    I have received a message from jeency, as below:

    Quote Originally Posted by jeency
    I have a problem..can you help me out with macro.
    Can you convert following data

    Company Name Service Name Price
    Company1 Service1 $1.01
    Company1 Service2 $1.02
    Company1 Service3 $1.03
    Company2 Service3 $2.03

    end result should look like

    Company Name Service1Service2Service3
    Company1 $1.01 $1.02 $1.03
    Company2 $0 $ 0 $2.03
    If we have just a few companies and some services, we could use Pivot Table to do it. But if the number of companies is too large, I think we should use VBA.

    Please see attatched file, 1 sheet is using Pivot Table and one sheet is using VBA code.

    I suppose that there are nearly 14,000 companies and 4 services.

    Note: I have asked this question in the Vietnamese forum: giaiphapexcel.com and have received help from ndu96081631 to finished.

    Link of my answer and those helps: Scripting.Dictionary
    Attached Files Attached Files
    Last edited by ptm0412; 07-18-2010 at 02:30 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Convert 1 Dimension Data to 2 dimensions

    Hi ptm0412
    A pivot table will handle 20,000 companies if there are only four service names very quickly . VBA would be extremely slow
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Convert 1 Dimension Data to 2 dimensions

    Please Login or Register  to view this content.

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Convert 1 Dimension Data to 2 dimensions

    For the record: jeency should not have used PM to ask a question in the first place!

    ptm, thanks for pulling that question into an open discussion.

  5. #5
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Re: Convert 1 Dimension Data to 2 dimensions

    Dear snb,
    Your code run very fast, but not common.
    What happend if I have real Service Names such as: Haircut, Nail, Make up, and Skin care?
    And, I suppose that we have not yet known how many companies and how many services, and all their names also.
    Your code may not work in actual case.

    Dear pike,
    I have used Pivot Table already. However, I am practising in writing VBA with Scripting Dictionary. Then I try to make the code so that it run as fast as possible.

    Thanks everybody.

    ptm0412

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1