+ Reply to Thread
Results 1 to 9 of 9

Transposing Values Using VBA

  1. #1
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Question Transposing Values Using VBA

    Hi,

    I am trying to transpose values from a horizontal format to a vertical format.

    Basically, I am trying to convert from table A1:V4 to table A9:D19.

    Originally, I had this conversion done with cell equations, but it is extremely slow and can be glitchy.
    I am hoping to streamline this process using VBA, but I am running into issues.

    Let me know what you all think!

    Example image.jpg
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Transposing Values Using VBA

    With the code below.

    Please Login or Register  to view this content.
    See the attached file.
    Last edited by oeldere; 08-05-2020 at 02:08 AM. Reason: correct code added after comments
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Re: Transposing Values Using VBA

    Hi,

    Thanks for the help!
    This is most of the way there, I just need to add in a section that removes all values with no pricing.

    Attachment 689648

  4. #4
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Re: Transposing Values Using VBA

    Also, the formatting isn't correct here. It is intended to have 4 columns, with the last two being QTY and Prc
    This script creates duplicate values... I'll see if I can sort it out. (see correct format below in A9:D19)

    Attachment 689652

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Transposing Values Using VBA

    I had the correct code yesterday, but I did not posted it.

    See #2 with the correct code and correct file.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Transposing Values Using VBA

    If you have many rows of data then this is faster.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Transposing Values Using VBA

    An alternative solution is to use Power Query/Get and Transform

    Please Login or Register  to view this content.
    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps

    M-code basics:
    - "let" is the start of a query
    - "in" is the closing of a query
    - each transformation step sits in between those 2 lines
    - each step line is ended by a comma, except the last one
    - "Source" is always the first step (Source Data)
    - After "in" you have the last step referenced
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  8. #8
    Registered User
    Join Date
    08-20-2018
    Location
    Mass, USA
    MS-Off Ver
    MS365 version 2303
    Posts
    28

    Re: Transposing Values Using VBA

    This helped a lot! Thanks!

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Transposing Values Using VBA

    Glad I could help.

    Thanks for marking the question solved.

    You can add reputation by clicking on the star * add reputation.


    I am curious wich solution you use.

+ 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. [SOLVED] Macro for transposing values
    By TimC1974 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-30-2017, 10:34 AM
  2. [SOLVED] Copying / transposing values in another sheet
    By grkchakri in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2015, 08:53 AM
  3. Replies: 9
    Last Post: 02-24-2015, 06:51 AM
  4. Transposing list of values with 6 zeroes in front to retain the zero after transposing
    By Lisa4legin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2013, 03:34 AM
  5. Transposing Date Values
    By Boendog in forum Excel General
    Replies: 6
    Last Post: 07-09-2012, 09:14 AM
  6. Keep last row format/values when transposing values from one worksheet to another
    By BuzzOffSweetheart in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2012, 02:27 PM
  7. transposing values top to bottom
    By Ted Metro in forum Excel General
    Replies: 3
    Last Post: 04-18-2005, 11:06 AM

Tags for this Thread

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