+ Reply to Thread
Results 1 to 2 of 2

How do I write a macro to unpivot data from wide to long

  1. #1
    Registered User
    Join Date
    03-12-2020
    Location
    MD
    MS-Off Ver
    64 bit
    Posts
    4

    How do I write a macro to unpivot data from wide to long

    Hello. I am trying to write vba code to unpivot some data. In the attached sheet, the raw data is on the "Raw_Data" tab and I would like to unpivot it (see "Unpivot" tab). Also I would like the "Unpivot" data to start in cell "A1". I tried recording the macro and going through the steps, however for some reason when I try to run the macro, I get the following error "A query with the name Table 1 already exists". Any help will be much appreciated.
    Attached Files Attached Files

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

    Re: How do I write a macro to unpivot data from wide to long

    An alternative to VBA is Power Query. Here is the Mcode

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    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

+ 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. Apps for excel that can transform wide data to long.
    By SaltySenator in forum Excel General
    Replies: 1
    Last Post: 11-09-2020, 05:15 PM
  2. [SOLVED] Wide to Long data transform
    By kayafueya in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-20-2020, 01:49 AM
  3. Wide to Long Data of Varying Length with No Macros/PivotTable
    By achpdsee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-05-2017, 08:58 PM
  4. [SOLVED] about restructure repeated measure data into long format from wide format
    By sohel_for in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-18-2015, 01:10 AM
  5. [SOLVED] Convert data from wide to long format
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2015, 06:52 PM
  6. Need help converting long data into wide form.
    By gbear in forum Excel General
    Replies: 4
    Last Post: 08-12-2013, 02:21 AM
  7. long to wide transformation of panel data with many variables
    By mradzik79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2012, 02:44 PM

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