+ Reply to Thread
Results 1 to 19 of 19

Data arrangement

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Data arrangement

    Dear all,
    I need a help to arrange my climate data. I have 30 years of climate data as you can see in the data sheet attached and I want the data to be arranged monthly as you can see in format sheet.
    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
    25,422

    Re: Data arrangement

    So you want the 31 days worth of data from January 1975 to appear in the first 31 cells of column B of the format sheet, then the data from 1976 to appear in the next 31 days, and so on for all the years? That would mean, though, that the data for February would quickly get out of alignment, as there are fewer days in that month, and the same would happen for the four 30-day months. Is that what you want?

    Pete

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    I dont really see how the arraingment you want, is significantly different/better to what you already have? All you are doing is changing rows to columns.

    What is your aim with this data?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    yes Pete that is what I want. I know the data length for each month will be different.

  5. #5
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    It is much different. I want to have all the data for January in one column, February and so on. I am doing a bias correction that demand individual months.

  6. #6
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    Pete, I can also take each months in a separate worksheet. forinstance, Januarys in sheet 2, Februarys in sheet 3 and so on to avoid any alignment issues. Thanks

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    If you can add a helper row to contain the days/month, it makes it a lot easier.

    I added a row at the top and entered 31/28/30 etc for the days (still working hon how to adjust Feb for leap years)

    Also, I changed your month headings from January/February etc to Jan/Feb so both sheets match.

    Then I used this, copied down and across, as needed...
    =INDEX(Data!$B$2:$AF$378,MATCH($A3-(INT(($A3-1)/B$1)*B$1)&"-"&B$2,Data!$A$2:$A$378,0),1+INT(($A3-1)/B$1))

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    OK, try this, it should catch leap years in Feb...
    =INDEX(Data!$B$2:$AF$378,MATCH($A3-(INT(($A3-1)/B$1)*B$1)&"-"&B$2,Data!$A$2:$A$378,0)+IF(B$2="Feb",IF(MOD(INDEX(Data!$B$1:$AF$1,1+INT(($A3-1)/B$1)),4)=0,1,0)),1+INT(($A3-1)/B$1))

  9. #9
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    Thanks, where I my copying the script to? can you use my data and attached it so that I can see more clearly? I have limited knowledge in coding

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    You would copy that into Format sheet B3, then copy down and across as far as you need.

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

    Re: Data arrangement

    I've been struggling to get one composite formula that you could put into B2 of the Format sheet and just copy across and down. I imagine this is a one-off, so I think the simplest approach is to put this formula in B2:

    =INDEX(Data!$B$2:$AF$32,MOD(ROWS($1:1)-1,31)+1,INT((ROWS($1:1)-1)/31)+1)

    This can be copied down to the bottom, and it will return all the January data.

    You can also copy this across into C2:M2, but before copying it down each column, you will need to make a few changes as shown in colour. The blue-coloured numbers are the number of days in each month, so for March, May, July, August, October and December you can leave those as 31, but for April, June, September and November you should change them to 30 (February is detailed below). You also need to change the range for each month, according to what is used on the Data sheet, i.e. the red numbers. January data covers rows 2 to 32 inclusive, February is in rows 34 to 62, March is 64 to 94, and so on. Once you have made these changes then you can copy the formulae down.

    February is unusual because it has a differing number of days, depending on whether it is a leap year or not. The easiest approach to this is to set the blue numbers to 28, but that would mean that you would miss the data for the 29th when it occurs. It might be easier to just put that in manually, rather than devise a complicated formula to just pick up one item of data every 4 years.

    Hope this helps.

    Pete

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    Pete, did you see the formula I put together?

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

    Re: Data arrangement

    Only after I posted mine, as I was trying for quite some time to come up with a way to have MOD(..28) for 28 rows and then MOD(..29) for the next 29 rows, then back to MOD(..28) for the next 84 rows for February, and then gave up and opted for the simpler approach (pragmatist). I was trying to avoid using a helper with this one, although I often do that in my solutions.

    Pete

  14. #14
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    Thanks peter. This work only that it didn't take care of the leap year.

  15. #15
    Registered User
    Join Date
    07-26-2013
    Location
    Norman,USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Data arrangement

    I copy the formula but it doesn't return any value. Do you mean i need to insert rows in the data sheet?

  16. #16
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    I got around the 28/29 days with this part of the MATCH...
    )+IF(B$2="Feb",IF(MOD(INDEX(Data!$B$1:$AF$1,1+INT(($A3-1)/B$1)),4)=0,1,0))

    =INDEX(Data!$B$2:$AF$378,MATCH($A3-(INT(($A3-1)/B$1)*B$1)&"-"&B$2,Data!$A$2:$A$378,0)+IF(B$2="Feb",IF(MOD(INDEX(Data!$B$1:$AF$1,1+INT(($A3-1)/B$1)),4)=0,1,0)),1+INT(($A3-1)/B$1))

    I could probably have done it without the helper, but the formula was already getting a bit messy...
    something like...
    +if(or(B$2="Jan",B$2="Mar"etc)1,0) for the month would take care of that

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Data arrangement

    See the attached for how I did this
    Attached Files Attached Files

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

    Re: Data arrangement

    Quote Originally Posted by akumagaavese View Post
    ... it didn't take care of the leap year...
    If you use 29 for the divisor for February (with the appropriate lookup range) then you will get zero for those years that are not leap years. It is easy to identify these and just delete those values.

    Hope this helps.

    Pete

  19. #19
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,655

    Re: Data arrangement

    This solution use no helper in the worksheet.
    My approach: with days running from A2:A931=1-930 = 930/31=30 years, I try to define day and year for each row.
    i.e A33=32 = day 1 of year 1976 (because 31 = day 31 of previous year 1975)
    Stay in B33, d-mmm should be: MOD($A33-1,31)+1&"-"&LEFT(B$1,3) = 1-Jan
    Year should be INT(($A33-1)/31)+Data!$B$1 = 1+1975 = 1976

    Then, Use INDEX to find the data:

    =INDEX(Data!$A$1:$AF$378,MATCH(MOD($A33-1,31)+1&"-"&LEFT(B$1,3),Data!$A$1:$A$378,0),MATCH(INT(($A33-1)/31)+Data!$B$1,Data!$A$1:$AF$1,0))

    The final formula in B2:

    Please Login or Register  to view this content.
    Drag down and accross.

    Note: 30 Feb, 31 Jun,...display blank.
    Attached Files Attached Files
    Quang PT

+ 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] data arrangement
    By akumagaavese in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-12-2015, 05:48 PM
  2. [SOLVED] Data Arrangement
    By Excel_Pa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2015, 06:27 AM
  3. Data arrangement
    By akumagaavese in forum Excel General
    Replies: 1
    Last Post: 03-13-2015, 04:12 PM
  4. Data arrangement
    By akumagaavese in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-13-2015, 02:59 PM
  5. data arrangement
    By tofimoon4 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-14-2010, 03:08 AM
  6. Data re-arrangement
    By SCT in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2009, 06:09 AM
  7. Data arrangement
    By kushalprakash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2006, 05:05 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