+ Reply to Thread
Results 1 to 8 of 8

Need assistance to automatically reformat an existing spreadsheet to a new format by Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Need assistance to automatically reformat an existing spreadsheet to a new format by Macro

    I am somewhat new to VBA let alone Excel 2010 and need some assistance in changing an existing format of a spreadsheet to a different format. I want to have a button or something they one can press to perform the task. I have a current report that is somewhat pivotted and I need to make it a linear one. I am attaching a spreadsheet with a sample. So my data allows multiple time points to be entered onto one line to make it easier to read. I need that to be transposed so that time is in one column going down the spreadsheet and not across. The rest of the data can be duplicated for each line. I want the macro to be flexible so that it will run if there are 3 sample or 100. I should scan down and continue until the end of the file. Can anyone help or give me a starting point on how to get this done.

    Thanks you in advance for any assistance.
    Isara
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    hi Isara-NJ, welcome to Excelforum, please check attachment, press Run button
    Attached Files Attached Files
    Last edited by watersev; 10-01-2012 at 04:57 PM.

  3. #3
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    THANK YOU SOOO MUCH!!! I will work with this and make any necessary tweaks to make it do exactly what I need.

    Isara

  4. #4
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    I need your help again, I found out I have to make a change to the code in the number of timepoints, but I'm not quite understanding how it all works. Can you explain what all the letters stand for & how the code is working so that I can modify the code some? I need to be able to adjust the number of timepoints to accomodate up to 9.

    Thanks!
    Isara

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    hi Isara, I've amended the code to process any amount of timepoints provided the structure of the initial data table layout stays the same, please check attachment

    Basically the code takes data to array, loops through the array, fills resulting array and outputs result to a new sheet. All those letters are just counters for rows, columns, timepoints.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    Thanks Watersev! OK so if a line of data doesn't have 9 timepoints will it leave a blank line in the new file or will it just skip it?

    Thanks again. This will be a really big help.
    Isara

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    Can you explain in detail just not to give you wrong reply?

  8. #8
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Need assistance to automatically reformat an existing spreadsheet to a new format by M

    Sorry, I found this information out after the fact but there may be some rows of data that have 9 timepoints and other data rows with less. So if I have a static header row with 9 timepoints on it some rows may be full while other lines will have blank fields in those timepoints they didn't do. I was asking you if a timepoint is blank will it create a blank row with all other data there except for a timepoint or will it skip the blank & only create a file with data filled rows. I've just tried it in your sample and it does create blank rows.The most ideal way would be that it skip the blank timepoints. I'll see if I can modify the existing code to do that. Thanks!

+ 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