Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Need help in using excel to re-arrange data in a specific manner  (Read 2734 times)

0 Members and 1 Guest are viewing this topic.

umairaasem

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows Vista
    Need help in using excel to re-arrange data in a specific manner
    « on: November 28, 2014, 02:34:47 AM »
    Hi,
     
    I have alot of data listed in the following manner (see first attachment)
     
    alpha beta gamma
     Apple 1 0 1
     Banana 2 1 1
     Orange 3 0 0
     
    I want to be able to re-arrange it in the following manner (see second attachment)
     
    Apple 1 alpha
     Apple 1 gamma
     Banana 2 alpha
     Banana 1 beta
     banana 1 gamma
     Orange 3 alpha
     
    Can anyone please guide me on how this is achievable using excel vba/programming/macros
     
    I shall really be grateful.
     
    Thank you so much
     

    [attachment deleted by admin to conserve space]

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Need help in using excel to re-arrange data in a specific manner
    « Reply #1 on: November 28, 2014, 04:12:04 PM »
    Is this homework?

    umairaasem

      Topic Starter


      Newbie

      • Experience: Beginner
      • OS: Windows Vista
      Re: Need help in using excel to re-arrange data in a specific manner
      « Reply #2 on: December 01, 2014, 02:11:36 AM »
      No no just something im trying to do at work. A whole database needs to be arranged in this manner.

      DaveLembke



        Sage
      • Thanked: 662
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Need help in using excel to re-arrange data in a specific manner
      « Reply #3 on: December 01, 2014, 10:57:51 AM »
      So this is a 'flat database' using Excel instead of a normal database in Access etc?

      This is an example of why flat databases should be avoided.

      If this is a flat database which I believe it is, your best bet would be to export this as a CSV and then have a program restructure the placement of the data as you want, and then save the changes to a new CSV, and then open that new CSV and have your data arranged in your flat database correctly

      ( OR )

      This may be able to be performed with a macro within Excel, however I would be very careful with macro use in Excel as for you will want to create a backup copy someplace before running a macro that will alter the arrangement of data, or else your flat database would be a worthless mix of correct and incorrect data per row.

      If this is an Access database or a database of some other kind that is not a flat database a report could be easily created in which you could select what columns to show info for ( ascending or descending ) and most importantly the data that is in the rows for the entry would all remain a child of the parent entry so you dont have to worry about your data getting moved to other rows and ending up with corruption basically in your data.

      Just out of curiosity, how many data entries do you have in your flat database if this is an Excel flat database?  You could export this and import it to Access and then have a much better method for generating reports and having your data correctly listed in ascending alpha numeric order etc without risk of data being moved to wrong locations which is what usually happens with Excel flat databases.

      Access and other databases reference each entry by parent and child entries. The parent entry is the initial entry which is linked to a unique identifier which is usually the primary key. The child entries have reference to the parent entry unique identifier so its like children with name tags so if you took all the children and grouped them together and they all looked similar you would be able to place the correct children back with the parents that the children go with as the best analogy I could come up with for why Access and a real database is better.

      With Excel, all children look the same but they are different, and you dont have the benefit of the children knowing who their parents are to run back to, and so you end up with a pool of data that is not referenced to the origin of it and this can spell disaster of what was once correct data being incorrect in which without a backup to refer to of a known good state, you would pretty much have to start from scratch or verify the flat database entries against say the inventory that it is for 3 of a specific item and 6 of another in which you find that you actually have 10 and then get to another item that says it has 10 in the flat messed up database that you only have 6 of etc.

      I use to use a flat database years ago before I learned how to create and use real transactional databases, and its definitely worth it to learn how to create and maintain one as for the headaches associated with a real database vs a flat database are very few if properly maintained and your careful with queries which can alter data in the database as dangerously as a macro in Excel if coded up/instructed incorrectly.

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: Need help in using excel to re-arrange data in a specific manner
      « Reply #4 on: December 01, 2014, 01:49:18 PM »
      Dave...it's for his workplace...which is even worse than Homework...
      " Anyone who goes to a psychiatrist should have his head examined. "