+ Reply to Thread
Results 1 to 10 of 10

Restructuring data

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Restructuring data

    Hi all,

    I’m trying to write some VBA which can reorganise my data but I literally have no idea where to start with this one. I’ve attached an example workbook of a before and after showing how my data is and how I need to transpose it.

    Can anyone provide any pointers? I was thinking I need a loop maybe?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Restructuring data

    I suspect your real data doenot look like the sample attached. You need to attach a realistic sample if the code does not produce the desired result.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Restructuring data

    HI AB,

    No my code does look like the attached, certainly in structure anyway. Only difference is content. Any ideas where to start?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Restructuring data

    There is a code attached to a button. When you press it, the output would be in new sheet. What I was trying to explain is if the code does not produce the desired result, you need to increase the sample data and layout. The code produces the correct result, but it is only based on two rows of data.

  5. #5
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Restructuring data

    That is excellent. Thank you for supplying the answer. I am fairly ok at reading VB and writing rudimentary code but I have no idea what yours is doing!

    I suspect I need to add:
    Please Login or Register  to view this content.
    somewhere but I'm not sure where?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Restructuring data

    It finds the last row in column A. It returns a long(Long integer). The last row with data before a blank row.

    This is not part of my code though.

  7. #7
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Restructuring data

    Thanks AB. When I run your code I get a subscript out of range error which I suspect is because my row range is larger than my example sheet. It's currently 158 rows (always 5 columns though). Sometimes though it might be more rows or less.

    Because I don't understand your code I'm not sure where I need to put in the finalrow code?

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Restructuring data

    As long as you have data starting in row 2 and there is no complete blank rows or columns, the code could handle any size.
    Could you please attach your sample?

  9. #9
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Restructuring data

    Hi AB,

    I see, thanks. I have attached a real sample of my data. It actually goes up to 18 columns. Is that why it doesn't work?

    Thank you for your help.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Restructuring data

    D_N_L,
    I did not get any error when I run the code. You have not included an output sheet. Please check the output on sheet5. If the output is different, please attach a new output.
    Attached Files Attached Files

+ 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. Restructuring 4 columns to 5
    By snelson600 in forum Excel General
    Replies: 1
    Last Post: 10-12-2013, 08:29 PM
  2. Restructuring data with a macro?
    By JAMatthews in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2013, 01:41 PM
  3. Restructuring Data
    By SimonNZ in forum Excel General
    Replies: 3
    Last Post: 09-22-2010, 10:24 PM
  4. restructuring data
    By Klipvis in forum Excel General
    Replies: 3
    Last Post: 10-21-2009, 05:30 AM
  5. Replies: 0
    Last Post: 02-15-2006, 03:47 PM

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