+ Reply to Thread
Results 1 to 10 of 10

Horizontal data Formula

  1. #1
    Registered User
    Join Date
    11-14-2016
    Location
    usa,CA
    MS-Off Ver
    2010
    Posts
    20

    Horizontal data Formula

    Hello Everyone,

    I would to come with a formula that i have a Cell A1 that have dates horizontally. Some dates don't have any amount and some have it, but I would like to see it Vertically referring Cell A1 with dates and amount in vertical way. Also, I dont want any "0" data...

    See attached for reference.

    Thanks,
    MO
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,811

    Re: Horizontal data Formula

    Why do you show the dates going backwards for CTR# 11950000, but going forwards for CTR# 11300000 ?

    What does the 01.19 signify at the end of the dates in column D ?

    Pete

  3. #3
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Horizontal data Formula

    A couple of questions in addition to Pete's:

    1) What does the minus signs in front of the CTR# 11950000 dates in col-D mean?

    2) Is this to be a "one-off" rearrangement of the worksheet or will it need to be done multiple times / regularly?

  4. #4
    Registered User
    Join Date
    11-14-2016
    Location
    usa,CA
    MS-Off Ver
    2010
    Posts
    20

    Re: Horizontal data Formula

    1) That's just a dash to show the date that I type it manually.

    2) I will get a file like that every month from our vendor.

    Thanks,
    Moustapha

  5. #5
    Registered User
    Join Date
    11-14-2016
    Location
    usa,CA
    MS-Off Ver
    2010
    Posts
    20

    Re: Horizontal data Formula

    Quote Originally Posted by Pete_UK View Post
    Why do you show the dates going backwards for CTR# 11950000, but going forwards for CTR# 11300000 ?

    What does the 01.19 signify at the end of the dates in column D ?

    Pete
    Dates I type it manually. Hope that helps.

    01.19 its the current month.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,811

    Re: Horizontal data Formula

    And how much data are you likely to have in your real file?

    Pete

  7. #7
    Registered User
    Join Date
    11-14-2016
    Location
    usa,CA
    MS-Off Ver
    2010
    Posts
    20

    Re: Horizontal data Formula

    Around 2630 rows of data

  8. #8
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Horizontal data Formula

    Here is a VBA solution. It assumes the following:
    The name of the source data (from vendor) worksheet is "Source"
    An empty worksheet named "Dest" exists. This is where the re-arranged data will be placed.

    I have chosen to provide a real date in column-D. It is derived from the months provided in source data row-1, but as row-1 is just text there is no year data available. For now I have assumed that the starting year in cell B1 is 2018. This can be changed easily if necessary by changing the startYear constant near the top of the VBA.

    To test this macro:
    1) Add/change the data on the source worksheet as desired.
    2) Clear the "Dest" worksheet
    3) Run the "reorg_data" macro.
    4) Verify that the reorganized data on the "Dest" worksheet is as desired.

    Here is the VBA:

    Please Login or Register  to view this content.

    See also the attached workbook
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-14-2016
    Location
    usa,CA
    MS-Off Ver
    2010
    Posts
    20

    Re: Horizontal data Formula

    it works perfect. Can you teach me please step by step how you started with this macro?

  10. #10
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Horizontal data Formula

    I'm not sure what you VBA knowledge level is. If you are just starting out then I would recommend that you find a few of the many online tutorials that interest you and study them. I also consider myself a rank amateur at VBA - there are many experts on this forum who would have made a better job of this - so don't necessarily take my code as a great model!

    That said, here's a summary.

    The heart of this VBA sub is the two nested for loops.

    The outer loop iterates around each row (except the header row) of the source worksheet and saves the CTR# of the row so that it can be output to potentially multiple rows of the destination worksheet.

    The inner loop iterates around each cell in the current source row. The "IF" statement ignores "amount" cells that are set to zero per your requirements.

    If the "amount" cell is not zero then a new row is written to the destination worksheet consisting of the CTR# and the "amount". The "round" function computes a rounded version of "amount" per your requirement. Computing the date, in particular the right year, is less than straightforward because the month in row-1 of the source data is just text, not a date and so there's a bit of math using the VBA month, Int and DateSerial functions in order to derive the date that I have written to col-D of the destination worksheet.

    That's it in summary. If you have specific questions I will be glad to try to answer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula for transform data horizontal.
    By inform in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2017, 02:53 PM
  2. Formula to get vertical data into horizontal format
    By razkowski in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-07-2015, 02:16 PM
  3. [SOLVED] sumproduct formula for horizontal data
    By Jules Pop in forum Excel General
    Replies: 7
    Last Post: 08-08-2014, 05:25 AM
  4. formula for converting vertical data set into horizontal
    By bsapaka in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2014, 09:29 PM
  5. Copying formula down with horizontal source data
    By NDF in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-26-2013, 10:38 PM
  6. Help with a macro formula to convert horizontal data into veritical data
    By shapenote1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2013, 06:27 PM
  7. [SOLVED] Copying and pasting Horizontal Data to Horizontal cells
    By jjin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2013, 01:14 AM

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