<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://ocotal.iarc.uaf.edu/index.php?action=history&amp;feed=atom&amp;title=Monthly_Averages</id>
	<title>Monthly Averages - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://ocotal.iarc.uaf.edu/index.php?action=history&amp;feed=atom&amp;title=Monthly_Averages"/>
	<link rel="alternate" type="text/html" href="http://ocotal.iarc.uaf.edu/index.php?title=Monthly_Averages&amp;action=history"/>
	<updated>2026-05-12T22:00:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://ocotal.iarc.uaf.edu/index.php?title=Monthly_Averages&amp;diff=1640&amp;oldid=prev</id>
		<title>137.229.29.95 at 20:47, 28 November 2011</title>
		<link rel="alternate" type="text/html" href="http://ocotal.iarc.uaf.edu/index.php?title=Monthly_Averages&amp;diff=1640&amp;oldid=prev"/>
		<updated>2011-11-28T20:47:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Use this program to compute monthly averages.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Option Explicit&lt;br /&gt;
Public Sub monthly_avg()&lt;br /&gt;
  Dim datecol As Integer&lt;br /&gt;
  Dim inputcol As Integer&lt;br /&gt;
  Dim outcol As Integer&lt;br /&gt;
  Dim worksheetz As Integer&lt;br /&gt;
  Dim startrow As Long&lt;br /&gt;
  Dim outputdate As Boolean&lt;br /&gt;
  Dim outputcount As Boolean&lt;br /&gt;
  Dim columnincr As Integer&lt;br /&gt;
  &lt;br /&gt;
  ' stuff that should be set just initially&lt;br /&gt;
  datecol = 1&lt;br /&gt;
  worksheetz = 3&lt;br /&gt;
  startrow = 4&lt;br /&gt;
  outputcount = True&lt;br /&gt;
  outputdate = True&lt;br /&gt;
  inputcol = 2&lt;br /&gt;
  outcol = 30&lt;br /&gt;
  Call avg_column(datecol, inputcol, outcol, worksheetz, startrow, outputdate, outputcount)&lt;br /&gt;
  &lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
Public Sub avg_column(datecol As Integer, inputcol As Integer, outcol As Integer, worksheetz As Integer, startrow As Long, outputdate As Boolean, outputcount As Boolean)&lt;br /&gt;
  Dim row As Long&lt;br /&gt;
  Dim count As Integer&lt;br /&gt;
  Dim themonth As Integer&lt;br /&gt;
  Dim curdata As Double&lt;br /&gt;
  Dim monthsum As Double&lt;br /&gt;
  Dim outrow As Integer&lt;br /&gt;
  &lt;br /&gt;
  outrow = startrow&lt;br /&gt;
  row = startrow&lt;br /&gt;
 &lt;br /&gt;
  themonth = Int(Format(Worksheets(worksheetz).Cells(row, datecol).Value, &amp;quot;MM&amp;quot;))&lt;br /&gt;
  curdata = Worksheets(worksheetz).Cells(row, inputcol).Value&lt;br /&gt;
  If Abs(curdata) &amp;lt; 6999 Then&lt;br /&gt;
    monthsum = curdata&lt;br /&gt;
    count = 1&lt;br /&gt;
  End If&lt;br /&gt;
  row = row + 1&lt;br /&gt;
  Do While Worksheets(worksheetz).Cells(row, datecol).Value &amp;lt;&amp;gt; &amp;quot;&amp;quot;&lt;br /&gt;
    If themonth = Int(Format(Worksheets(worksheetz).Cells(row, datecol).Value, &amp;quot;MM&amp;quot;)) Then&lt;br /&gt;
      ' same day&lt;br /&gt;
      curdata = Worksheets(worksheetz).Cells(row, inputcol).Value&lt;br /&gt;
      If Abs(curdata) &amp;lt; 6999 Then&lt;br /&gt;
        monthsum = monthsum + curdata&lt;br /&gt;
        count = count + 1&lt;br /&gt;
      End If&lt;br /&gt;
    Else:&lt;br /&gt;
      ' new day, do some outputting&lt;br /&gt;
      If outputdate = True Then&lt;br /&gt;
        ' output the day&lt;br /&gt;
        Worksheets(worksheetz).Cells(outrow, outcol).Value = themonth&lt;br /&gt;
        If count &amp;gt; 0 Then&lt;br /&gt;
          ' output daily average&lt;br /&gt;
          Worksheets(worksheetz).Cells(outrow, outcol + 1).Value = monthsum / count&lt;br /&gt;
        End If&lt;br /&gt;
        If outputcount = True Then&lt;br /&gt;
          ' output the count if the boolean is true&lt;br /&gt;
          Worksheets(worksheetz).Cells(outrow, outcol + 2).Value = count&lt;br /&gt;
        End If&lt;br /&gt;
      Else:&lt;br /&gt;
        ' don't output the day&lt;br /&gt;
        If count &amp;gt; 0 Then&lt;br /&gt;
          ' output daily average&lt;br /&gt;
          Worksheets(worksheetz).Cells(outrow, outcol).Value = monthsum / count&lt;br /&gt;
        End If&lt;br /&gt;
        If outputcount = True Then&lt;br /&gt;
          ' output the count if the boolean is true&lt;br /&gt;
          Worksheets(worksheetz).Cells(outrow, outcol + 1).Value = count&lt;br /&gt;
        End If&lt;br /&gt;
      End If&lt;br /&gt;
      outrow = outrow + 1&lt;br /&gt;
      ' okay, done outputting.  Now to ingest the new data as before.&lt;br /&gt;
      ' first reset the vars.&lt;br /&gt;
      count = 0&lt;br /&gt;
      monthsum = 0&lt;br /&gt;
      themonth = Int(Format(Worksheets(worksheetz).Cells(row, datecol).Value, &amp;quot;MM&amp;quot;))&lt;br /&gt;
      curdata = Worksheets(worksheetz).Cells(row, inputcol).Value&lt;br /&gt;
      If Abs(curdata) &amp;lt; 6999 Then&lt;br /&gt;
        monthsum = curdata&lt;br /&gt;
        count = 1&lt;br /&gt;
      End If&lt;br /&gt;
      &lt;br /&gt;
    End If&lt;br /&gt;
    row = row + 1&lt;br /&gt;
  Loop&lt;br /&gt;
    ' drop in the stuff for the last day of year.&lt;br /&gt;
    ' new day, do some outputting&lt;br /&gt;
    If outputdate = True Then&lt;br /&gt;
     ' output the day&lt;br /&gt;
     Worksheets(worksheetz).Cells(outrow, outcol).Value = themonth&lt;br /&gt;
     If count &amp;gt; 0 Then&lt;br /&gt;
       ' output daily average&lt;br /&gt;
       Worksheets(worksheetz).Cells(outrow, outcol + 1).Value = monthsum / count&lt;br /&gt;
     End If&lt;br /&gt;
     If outputcount = True Then&lt;br /&gt;
       ' output the count if the boolean is true&lt;br /&gt;
       Worksheets(worksheetz).Cells(outrow, outcol + 2).Value = count&lt;br /&gt;
     End If&lt;br /&gt;
   Else:&lt;br /&gt;
     ' don't output the day&lt;br /&gt;
     If count &amp;gt; 0 Then&lt;br /&gt;
       ' output daily average&lt;br /&gt;
       Worksheets(worksheetz).Cells(outrow, outcol).Value = monthsum / count&lt;br /&gt;
     End If&lt;br /&gt;
     If outputcount = True Then&lt;br /&gt;
       ' output the count if the boolean is true&lt;br /&gt;
       Worksheets(worksheetz).Cells(outrow, outcol + 1).Value = count&lt;br /&gt;
     End If&lt;br /&gt;
   End If&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>137.229.29.95</name></author>
		
	</entry>
</feed>