+ Reply to Thread
Results 1 to 7 of 7

Reposition data on sheet and calculate how many times it occurs

  1. #1
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Los Angeles, USA
    MS-Off Ver
    2003, 2010, 365
    Posts
    320

    Reposition data on sheet and calculate how many times it occurs

    Hi,

    I have a set of data which has an initail layout as below:

    Cell separator = |

    Order#1|Order#2|CompName|Date|Item#|Quantity|Price|TotalPrice

    and after VBA would be changed to

    CompName|
    QuantityofItem#s|Order#1|Order#2|Date|
    Item#|Quantity|Price|TotalPrice|

    The above QuantityofItem#s would be calculated by the number of times the Order#1 appears

    I have made a mistake on the attached Example.xls so please use the one on my next post further down the page as it shows on the tabs the data before and after applying VBA.

    Thanks,

    David
    Attached Files Attached Files
    Last edited by djfscouse; 02-17-2013 at 01:45 PM. Reason: incorrect example attached

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Reposition data on sheet and calculate how many times it occurs

    Why do you want to do this?
    Your original data is in a more usable form than your requested result.

    What determines 121228098 in C16?

    See this workbook. It isn't a solution for your request, it is only a "visual" aid towards one.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Reposition data on sheet and calculate how many times it occurs

    Hi,

    I agree with Marcol. Your original data is more easily analysed/summarised as it is.

    If you really do want another format then have you considered a Pivot Table? Add a new row of column label headers with values A:H and then put E in the Row labels PT area, A, B & D in the column label area and E in the Values area.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Los Angeles, USA
    MS-Off Ver
    2003, 2010, 365
    Posts
    320

    Re: Reposition data on sheet and calculate how many times it occurs

    Thank you both for your responses, the reason I need the output to be as my attachment is because it is the required layout of a software I want to import the data to.

    The 121228098 in C16 is the Order#2, I made a mistake on my previous upload of the Example.xls file as it was supposed to be the same number for C17 and C18 also. Attached is the corrected document, sorry for the confusion.

    The converted layout should be as below
    CompName|
    QuantityofItem#s|Order#1|Order#2|Date|
    Item#|Quantity|Price|TotalPrice|
    Item#|Quantity|Price|TotalPrice|
    Item#|Quantity|Price|TotalPrice|

    I appreciate the visual aid which will give me a way to figure out how to apply the VBA for the final solution.

    Thanks,

    David
    Attached Files Attached Files

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Reposition data on sheet and calculate how many times it occurs

    Perhaps this macro could shuffle your data the way you wish.

    Please Login or Register  to view this content.
    Alf
    Last edited by Alf; 02-17-2013 at 05:36 PM. Reason: Removed unneeded code.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Reposition data on sheet and calculate how many times it occurs

    See if this formula based workbook is of any use, it can be modified to return more than one table if needed.

    Select from the drop-down in Sheet "Summary" B2
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Los Angeles, USA
    MS-Off Ver
    2003, 2010, 365
    Posts
    320

    Re: Reposition data on sheet and calculate how many times it occurs

    Thanks for the formula based workbook Marcol I appreciate your efforts, Alf's solution is ideal for my project so thank you very much.

    David

+ 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