+ Reply to Thread
Results 1 to 6 of 6

computing annual maxima

  1. #1
    Registered User
    Join Date
    04-04-2009
    Location
    Rancho Cordova, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    computing annual maxima

    I have daily streamflow data for a large number of years. One column is the date and the second column is the streamflow value. I want to compute the maximum value and the 3-day maximum (largest average value for any consecutive 3-day period)for each water year (starts on October 1 and ends on Sept 30). Of course the number of days each year varies by one during leap years. Any help would be greatly appreciated!
    Last edited by chuck_p; 04-06-2009 at 11:44 AM.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: computing annual maxima

    Hi, Try this:-
    It will Give you a Max for 3 consegutive day for each Year in column "A" by Date.
    Results in column "C".
    If Data does not start in "A1", change the "1" in "FirstYr = Year(Cells(1, "A").Value)" to whatever is the start Row number
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    04-04-2009
    Location
    Rancho Cordova, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: computing annual maxima

    Thanks for the reply Mick. I didn't get very far with your suggested code, however. I got a run-time error and the code statement it didn't like was the following:

    LastYr = Year(Cells(Range("A" & Rows.Count).End(x1Up).Row, "A").Value)

    I'm a newbie, so I am not sure of the context for this kind of range referencing. My suspicion is that it does not like the " End(x1Up) " part, but I only know enough to be dangerous. Thanks for your help!

    Chuck_p

  4. #4
    Registered User
    Join Date
    04-04-2009
    Location
    Rancho Cordova, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Smile Re: computing annual maxima

    Thanks Mick -- It worked after I corrected my own mistake in transcribing your code. I appreciate your prompt and very able assistance...

    Chuck

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: computing annual maxima

    Hi, If you've got it working you'll notice you have the Average/Max but no years.
    This code should address that.
    Column "C" should now show the year taken from column "A" (Dates) and Column "D" should show the Max/Average Result relating to that year.
    If its not quite working Correctly , perhaps you could post you File (.xls).
    Please Login or Register  to view this content.
    Regards Mick

  6. #6
    Registered User
    Join Date
    04-04-2009
    Location
    Rancho Cordova, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: computing annual maxima

    Thanks Mick, I did add the year. Thanks to your help, I just learned a whole bunch about macros/vba programming using cell range references!
    ..chuck_p

+ 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