Consulting

Results 1 to 4 of 4

Thread: I'm new to this and trying to fix an error

  1. #1

    I'm new to this and trying to fix an error

    alright so my brother made this program for getting money totals at a business, its giving me error #62 "Input past end of file" i'll paste the code, and you may need to see the file its writing to also
    [vba]
    Sub SumMonth()
    Dim Starting1() As Double
    Dim Starting2() As Double
    Dim Bank() As Double
    Dim Side1Bank() As Double
    Dim Side2Bank() As Double
    Dim diff() As Double
    Dim dates() As Date
    Dim ccard() As Double
    Dim cash() As Double
    Dim totalSide1 As Double
    Dim totalSide2 As Double
    Dim totalBank As Double
    Dim totaldiff As Double
    Dim totalccard As Double
    Dim totalcash As Double
    Dim months As Date
    totalSide1 = 0
    totalSide2 = 0
    totalBank = 0
    totaldiff = 0
    totalccard = 0
    totalcash = 0
    months = InputBox("enter the month, the 1st of the month, and then the year (ex. 07/01/2005)")
    Open "C:\Documents and Settings\All Users\Documents\tills\Till_Data.txt" For Input As #1
    Dim counter As Integer
    counter = 0

    Dim temp, temp1, temp2, temp3, temp4, temp5, temp7, temp8 As Double
    Dim temp6 As String
    Do While Not EOF(1)
    counter = counter + 1
    Input #1, temp, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8
    Loop
    Close #1

    ReDim Starting1(counter + 1) As Double
    ReDim Starting2(counter + 1) As Double
    ReDim Bank(counter + 1) As Double
    ReDim Side1Bank(counter + 1) As Double
    ReDim Side2Bank(counter + 1) As Double
    ReDim diff(counter + 1) As Double
    ReDim dates(counter + 1) As Date
    ReDim ccard(counter + 1) As Double
    ReDim cash(counter + 1) As Double

    Dim i As Integer
    Range("A1").Select
    For i = 1 To counter + 5
    ActiveCell = ""
    ActiveCell.Offset(0, 1) = ""
    ActiveCell.Offset(0, 2) = ""
    ActiveCell.Offset(0, 3) = ""
    ActiveCell.Offset(0, 4) = ""
    ActiveCell.Offset(0, 5) = ""
    ActiveCell.Offset(0, 6) = ""
    ActiveCell.Offset(1, 0).Select
    Next i
    Open "C:\Documents and Settings\All Users\Documents\tills\Till_Data.txt" For Input As #1

    For i = 1 To counter
    Input #1, Starting1(i), Starting2(i), Bank(i), Side1Bank(i), Side2Bank(i), diff(i), dates(i), ccard(i), cash(i)
    Next i
    Close #1
    Range("A1").Select
    ActiveCell = "Date"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "Bank Side 1"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "Bank Side 2"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "Bank Total"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "difference"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "Credit Card"
    ActiveCell.Offset(0, 1).Select
    ActiveCell = "Cash Depositted"
    ActiveCell.Offset(1, -6).Select
    For i = 1 To counter
    If (Month(dates(i)) = Month(months)) Then
    If (Year(dates(i)) = Year(months)) Then
    ActiveCell = dates(i)
    ActiveCell.Offset(0, 1) = Side1Bank(i)
    totalSide1 = totalSide1 + Side1Bank(i)
    ActiveCell.Offset(0, 2) = Side2Bank(i)
    totalSide2 = totalSide2 + Side2Bank(i)
    ActiveCell.Offset(0, 3) = Bank(i)
    totalBank = totalBank + Bank(i)
    ActiveCell.Offset(0, 4) = diff(i)
    totaldiff = totaldiff + diff(i)
    ActiveCell.Offset(0, 5) = ccard(i)
    totalccard = totalccard + ccard(i)
    ActiveCell.Offset(0, 6) = cash(i)
    totalcash = totalcash + cash(i)
    ActiveCell.Offset(1, 0).Select
    End If
    End If
    Next i
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Offset(0, 1) = totalSide1
    ActiveCell.Offset(0, 2) = totalSide2
    ActiveCell.Offset(0, 3) = totalBank
    ActiveCell.Offset(0, 4) = totaldiff
    ActiveCell.Offset(0, 5) = totalccard
    ActiveCell.Offset(0, 6) = totalcash

    End Sub
    [/vba] the highlighted area is what the debugger brings up as the problem, saying that temp= empty and temp1=empty...... even though both clearly have numbers in them on the excel sheet and the data sheetHELP!

    here is the data file (obviously not in VBA, its in a .txt file so i can't attach it):
    [vba] 421.56,70.54,1678.89,875.81,803.08,.48,#2005-07-01#,0,0
    309.5,68.32,2230,1363.49,866.51,-12.57,#2005-07-02#,0,0
    206.85,64.55,2475.39,1330.84,1144.55,-17.61,#2005-07-03#,0,0
    246.02,67.91,2439.9,1211.28,1228.62,-1.87,#2005-07-04#,0,0
    179.47,80.22,1594.82,939.13,655.69,7.47,#2005-07-05#,0,0
    270.9,63.69,1361.18,810.8,550.38,-3.97,#2005-07-06#,0,0
    335.93,71.23,1324.32,807.73,516.59,17.86,#2005-07-07#,0,0
    374.65,67.15,1741.09,1015.4,725.69,-5.92,#2005-07-08#,0,0
    295.81,70.12,1728.9,1025.02,703.88,2.47,#2005-07-09#,0,0
    181.88,70.34,2612.66,1423.45,1189.21,-9.44,#2005-07-10#,0,0
    286.49,66.41,1201.15,669.15,532,.57,#2005-07-11#,0,0
    226.62,68.55,1623.93,1105.27,518.66,-2.44,#2005-07-12#,0,0
    299.39,69.9,1519.33,905.64,613.69,-5.67,#2005-07-13#,0,0
    229.2,66.3,1909.6,1183.28,726.32,7.14,#2005-07-14#,0,0
    296.58,70.33,1910.18,1100.89,809.29,1.68,#2005-07-15#,0,0
    228.75,53.3,2063.84,1228.51,835.33,-.31,#2005-07-16#,0,0
    263.97,62.81,2205.99,1265.22,940.77,-26.11,#2005-07-17#,0,0
    205.98,78.45,1282.15,884.66,397.49,3.4,#2005-07-18#,0,0
    287.6,71.89,1682.52,1140.11,542.41,-.25,#2005-07-19#,0,0
    224.42,67.3,1447.54,895.31,552.23,-.59,#2005-07-20#,0,0
    302.88,76.96,1385.86,792.73,593.13,-1.13,#2005-07-21#,0,0
    226.2,68.41,1922.49,1007.65,914.84,-2.32,#2005-07-22#,0,0
    273.41,84.64,1597.71,894.87,702.84,5.18,#2005-07-23#,0,0
    312.11,63.17,2264.38,1361.71,902.67,-4.27,#2005-07-24#,0,0
    271.47,69.26,932.11,620.04,312.07,.27,#2005-07-25#,0,0
    237.33,66.78,1074.79,662.32,412.47,-1.56,#2005-07-26#,0,0
    313.31,62.99,1426.93,787.39,639.54,-10.8,#2005-07-28#,0,0
    265.33,58.06,1382.94,854.2,528.74,-.6,#2005-07-28#,0,0
    335.77,70.11,1566.51,951.19,615.32,.72,#2005-07-29#,0,0
    260.76,62.7,1810.21,1087.89,722.32,-.54,#2005-07-30#,0,0
    308.06,63.36,2332.71,1306.04,1026.67,.34,#2005-07-31#,0,0
    234.63,64.2,1465.3,920.6,544.7,2.9,#2005-08-01#,0,0
    324.02,71.97,1210.71,676.38,534.33,1.64,#2005-08-02#,0,0
    285.36,62.4,1302.01,791.25,510.76,-3.38,#2005-08-03#,0,0
    262.78,54,1235.71,762.69,473.02,29.38,#2005-08-04#,0,0
    269.69,49.86,1704.74,1007.94,696.8,-42.18,#2005-08-05#,0,0
    197.78,59.14,2107.4,1173.62,933.78,-11.57,#2005-08-06#,0,0
    233.65,80.48,1971.66,1079.52,892.14,-2.14,#2005-08-07#,0,0
    347,73.15,1245.72,781.88,463.84,-5.77,#2005-08-08#,0,0
    306.56,69.45,1055.38,714.79,340.59,.07,#2005-08-09#,0,0
    269.74,72.7,1196.08,797.32,398.76,5.45,#2005-08-10#,0,0
    378.25,65.11,956.35,503.73,452.62,-10.42,#2005-08-11#,0,0
    344.31,84.91,1522.38,917.65,604.73,1.65,#2005-08-12#,0,0
    278.73,67.56,1297.53,830.58,466.95,-6.15,#2005-08-13#,0,0
    190.55,75.79,2231.96,1235.95,996.01,9.1,#2005-08-14#,0,0
    314.59,73.64,900.36,555.22,345.14,4.95,#2005-08-15#,0,0
    274.7,63.73,1337.06,851.12,485.94,-1.7,#2005-08-16#,0,0
    370.63,64.99,1029.23,645.6,383.63,4.21,#2005-08-17#,0,0
    342.51,75,944.59,742.56,202.03,-.54,#2005-08-18#,0,0
    429.08,52.83,1156.63,681.6,475.03,-.51,#2005-08-19#,0,0
    292.98,63.97,1338.11,935.45,402.66,-10.16,#2005-08-20#,0,0
    190.78,71.28,1938.59,1185.72,752.87,13.73,#2005-08-21#,0,0
    308.71,61.01,794.18,425.17,369.01,-.14,#2005-08-22#,0,0
    265.78,75.48,1088.27,713.27,375,-5.13,#2005-08-23#,0,0
    374.32,70.32,791.7,491.12,300.58,-.19,#2005-08-24#,0,0
    349.35,71.36,1031.96,697.86,334.1,-4.82,#2005-08-25#,0,0
    402.82,71.59,1210.02,689.31,520.71,-1.87,#2005-08-26#,0,0
    242.18,67.26,1368.2,865.05,503.15,-.71,#2005-08-27#,0,0
    180.01,70.79,1885.7,993.78,891.92,-.24,#2005-08-28#,0,0
    301.63,61.49,615.1,348.51,266.59,-9.98,#2005-08-29#,0,0
    400.7,69.07,984.39,544.49,439.9,.39,#2005-08-30#,0,0
    237.75,72.87,909.99,636.28,273.71,-4.92,#2005-08-31#,0,0
    352.48,62.44,750.46,488.14,262.32,-7.84,#2005-09-01#,0,0
    297.18,78.07,1464.17,950.48,513.69,.41,#2005-09-02#,0,0
    269.52,68.25,707.85,536.55,171.3,-.71,#2005-09-03#,0,0
    203.5,79.47,1836.57,1129.94,706.63,-6.24,#2005-09-04#,0,0
    277.92,69.71,1688.51,848.72,839.79,-4.88,#2005-09-05#,0,0
    285.94,64.5,680.69,501.21,179.48,1.99,#2005-09-06#,0,0
    266.52,64.1,721.88,564.03,157.85,-5.03,#2005-09-07#,0,0
    231.07,69.54,799.68,547.08,252.6,.16,#2005-09-08#,0,0
    337.46,67.14,843.33,527.93,315.4,-.74,#2005-09-09#,0,0
    192.46,76.15,1359.21,895.95,463.26,-4.83,#2005-09-10#,0,0
    272.05,62.61,1240.43,763.73,476.7,-1.18,#2005-09-11#,0,0
    235.15,70.09,537.41,405.84,131.57,2.08,#2005-09-12#,0,0
    226.17,64.96,656.14,526.52,129.62,-.59,#2005-09-13#,0,0
    212.37,68.96,753.38,573.38,180,2.78,#2005-09-14#,0,0
    184.58,72.41,797.07,628.91,168.16,3.02,#2005-09-15#,0,0
    207.46,58.58,947.49,608.22,339.27,1.81,#2005-09-16#,0,0
    175.01,70.7,830.4,614.41,215.99,-1.62,#2005-09-17#,0,0
    236.76,67.32,1334.95,708.35,626.6,-2.68,#2005-09-18#,0,0
    231.85,57,603.38,488.91,114.47,1.1,#2005-09-19#,0,0
    189.07,62.87,834.33,650.42,183.91,1.4,#2005-09-20#,0,0
    160.69,68.71,722.07,581.63,140.44,2.45,#2005-09-21#,0,0
    286.21,63.65,468.28,312.46,155.82,-.8,#2005-09-22#,0,0
    248.59,71.05,746.5,581.41,165.09,.93,#2005-09-23#,0,0
    211.24,61.91,921.73,771.55,150.18,-.04,#2005-09-24#,0,0
    166.81,62.92,834.34,629.87,204.47,-1.64,#2005-09-25#,0,0
    156.58,60.76,524.66,438.63,86.03,-.24,#2005-09-26#,0,0
    270.98,59.96,484.55,335.16,149.39,.29,#2005-09-27#,0,0
    249.58,52.94,517.76,453.65,64.11,-2.96,#2005-09-28#,0,0
    235.36,33.29,766.15,635.53,130.62,-1.45,#2005-09-29#,0,0
    214.06,61.09,1010.66,731.56,279.1,-.36,#2005-09-30#,0,0
    160.95,63.48,1086.61,801.61,285,-.21,#2005-10-01#,0,0
    241.89,64.7,1205.82,765.98,439.84,-.52,#2005-10-02#,0,0
    219.04,61.84,839.07,738.69,100.38,-.87,#2005-10-03#,0,0
    197.3,61.84,469.5,469.5,0,.41,#2005-10-04#,0,0
    188.68,61.84,422.41,422.41,0,-.28,#2005-10-05#,0,0
    173.66,61.84,480.39,480.39,0,.93,#2005-10-06#,0,0
    293.28,48.15,436.68,391.91,44.77,-10.72,#2005-10-07#,0,0
    260.06,44.95,964.59,884.37,80.22,-2.44,#2005-10-08#,0,0
    216.4,75.25,1045.17,837.15,208.02,11.71,#2005-10-09#,0,0
    222.45,49.09,815.82,702.56,113.26,.15,#2005-10-10#,0,0
    210.57,67.07,788.25,710.44,77.81,-.14,#2005-10-11#,0,0
    206.26,49.12,723.08,623.08,100,-.34,#2005-10-12#,0,0
    179.29,44.72,975.95,935.95,40,0,#2005-10-13#,0,0
    166.73,62.46,1151.14,1027.78,123.36,.75,#2005-10-14#,0,0
    130.85,45.26,1307.26,997.98,309.28,-.07,#2005-10-15#,0,0
    43.87,28.81,1682.64,1215.71,466.93,3.65,#2005-10-16#,0,0
    152.64,28.81,536.06,536.06,0,.68,#2006-02-25#,0,0
    244.47,28.81,704.25,704.25,0,-1.42,#2006-02-26#,0,0
    216.62,43.97,643.2,548.2,95,1.57,#2006-02-27#,0,0
    196.45,43.97,683.54,683.54,0,4.94,#2006-02-28#,0,0
    164.32,60.13,529.96,462.74,67.22,-.62,#2006-03-01#,0,0
    268.54,62.62,437.72,382.13,55.59,-8.49,#2006-03-02#,0,0
    234.3,64.2,769.59,705.26,64.33,.05,#2006-03-03#,0,0
    222.99,48.22,791.87,596.54,195.33,5.6,#2006-03-04#,0,0
    168.47,65.43,1019.87,895.44,124.43,6.1,#2006-03-05#,0,0
    150.02,45.15,604.76,471.5,133.26,.26,#2006-03-06#,0,0
    239.55,59.72,347.68,297.68,50,-.49,#2006-03-07#,0,0
    208.86,65.14,730.28,617.36,112.92,.87,#2006-03-08#,0,0
    163.61,66.31,738.24,568.24,170,.8,#2006-03-09#,0,0
    270.51,66.11,857.25,681.25,176,2.29,#2006-03-10#,0,0
    217.76,69.51,959.85,764.92,194.93,.22,#2006-03-11#,0,0
    187.33,59.46,880.91,688.2,192.71,2.12,#2006-03-12#,0,0
    179.74,59.46,290.02,290.02,0,1.53,#2006-03-13#,0,0
    154.9,53.96,517.27,397.39,119.88,.52,#2006-03-14#,0,0
    272.28,43.31,477.76,427.76,50,.04,#2006-03-15#,0,0
    278.99,51.03,447.75,347.8,99.95,.97,#2006-03-16#,0,0
    229.73,70.27,712.97,596.31,116.66,-.29,#2006-03-17#,0,0
    199.06,74.35,890.67,722.95,167.72,-12.12,#2006-03-18#,0,0
    163.47,65.21,1153.45,844,309.45,-.93,#2006-03-19#,0,0
    138.59,63.55,630.92,585.92,45,-.34,#2006-03-20#,0,0
    243.18,60.96,543.77,393.69,150.08,5.66,#2006-03-21#,0,0
    224.46,59.12,621.26,544.05,77.21,-1.9,#2006-03-22#,0,0
    219.46,44.17,478.97,428.97,50,4.65,#2006-03-23#,0,0
    210.9,55.52,751.17,587.83,163.34,-3.07,#2006-03-24#,0,0
    168.4,53.87,902.35,686.88,215.47,-3.79,#2006-03-25#,0,0
    131.95,55.67,1168.45,826.3,342.15,.31,#2006-03-26#,0,0
    98.92,64.1,516,461,55,-.2,#2006-03-27#,0,0
    218.65,63.93,538.56,384.95,153.61,.08,#2006-03-28#,0,0
    193.71,61.53,819.42,699.82,119.6,-.4,#2006-03-29#,0,0
    316.26,52.4,604.69,492.61,112.08,4.06,#2006-03-30#,0,0
    302.85,61.43,634.04,568.63,65.41,-.23,#2006-03-31#,0,0
    267.4,55.28,930.05,792.53,137.52,-2.68,#2006-04-01#,0,0
    206.12,64.18,1147.35,911.46,235.89,-8.26,#2006-04-02#,0,0
    142.21,45.07,728.26,604.08,124.18,1.29,#2006-04-03#,0,0
    260.54,67.25,853.98,618.08,235.9,-.48,#2006-04-04#,0,0
    223.15,70.22,1087.1,747.38,339.72,3.2,#2006-04-05#,0,0
    199.9,53.97,764.71,605.88,158.83,-5.41,#2006-04-06#,0,0
    287.95,64.49,861.91,577.35,284.56,-6.53,#2006-04-07#,0,0
    216.58,63.88,1584.22,1213.93,370.29,-6.99,#2006-04-08#,0,0
    197.87,67.58,1528.38,980.35,548.03,-17.46,#2006-04-09#,0,0
    256.45,68.9,1236.95,746.43,490.52,24.8,#2006-04-10#,0,0
    242.77,56.27,702.95,490.83,212.12,3.21,#2006-04-11#,0,0
    184.65,70.51,1315.66,926.82,388.84,8.73,#2006-04-12#,0,0
    254.71,69.77,1189.94,807.06,382.88,-2.36,#2006-04-13#,0,0
    259.46,58.52,1600.91,934.7,666.21,-26.39,#2006-04-14#,0,0
    165.36,37.36,1958.85,1237.03,721.82,13.49,#2006-04-15#,0,0
    81.38,67.39,1638.76,991.54,647.22,-.25,#2006-04-16#,0,0
    307.56,57.61,893.73,504.83,388.9,.98,#2006-04-17#,0,0
    280.77,57.71,1010.86,818.85,192.01,-.58,#2006-04-18#,0,0
    265.36,66.56,637.56,518.99,118.57,-.47,#2006-04-19#,0,0
    222.82,61.8,728.22,592.23,135.99,-1.24,#2006-04-20#,0,0
    355.09,66.22,762.1,544.28,217.82,-1.07,#2006-04-21#,0,0
    275.46,70.51,1614.62,997.79,616.83,-9.95,#2006-04-22#,0,0
    188.91,70.55,2088.82,1223.08,865.74,-4.33,#2006-04-23#,0,0
    175.86,52.08,434.5,369.5,65,.36,#2006-04-24#,0,0
    285.88,64.41,891.62,592.52,299.1,-.69,#2006-04-25#,0,0
    233.87,70.36,1122.8,766.05,356.75,-5.19,#2006-04-26#,0,0
    303.06,68.63,1313.88,851.17,462.71,-.73,#2006-04-27#,0,0
    254.23,67.5,731.51,561.49,170.02,-.77,#2006-04-28#,0,0
    228.46,62.78,830.96,595.37,235.59,1.16,#2006-04-29#,0,0
    173.29,61.35,1092.61,821.67,270.94,-.65,#2006-04-30#,0,0
    283.18,63.47,444,349.77,94.23,-1.38,#2006-05-01#,0,0
    233.06,65.29,1088.19,745.12,343.07,-1.22,#2006-05-02#,0,0
    195.17,73.61,727.61,541.58,186.03,-1.18,#2006-05-03#,0,0
    183.6,73.25,648.6,501.38,147.22,-.5,#2006-05-04#,0,0
    315.02,74.02,1014.36,629.95,384.41,-1.44,#2006-05-05#,0,0
    215.1,69.68,1702.96,990.8,712.16,5.24,#2006-05-06#,0,0
    273.52,69.32,1774.94,912.09,862.85,-15.49,#2006-05-07#,0,0
    234.06,60.83,920.2,628.02,292.18,2.47,#2006-05-08#,0,0
    198.95,53.16,984.53,724.01,260.52,-5.51,#2006-05-09#,0,0
    293.93,68.16,632.11,430.14,201.97,.01,#2006-05-10#,0,0
    262.73,62.31,820.17,670.17,150,-3.26,#2006-05-11#,0,0
    226.55,70.79,823.5,688.04,135.46,-5.26,#2006-05-12#,0,0
    183.45,69.85,1259.53,752.59,506.94,-19.28,#2006-05-13#,0,0
    259.78,61.08,1750.06,939.99,810.07,-1.9,#2006-05-14#,0,0
    194.62,71.66,1160.26,860.79,299.47,-5.1,#2006-05-15#,0,0
    281.69,60.62,1094.83,711.59,383.24,2.67,#2006-05-16#,0,0
    245.07,71.57,1156.5,804.63,351.87,-2.16,#2006-05-17#,0,0
    323.36,61.44,1092.8,705.7,387.1,-4.32,#2006-05-18#,0,0
    258.96,79.31,1704.56,1058.33,646.23,-5.15,#2006-05-19#,0,0
    179.6,60.71,1751.22,1022.71,728.51,-14.84,#2006-05-20#,0,0
    244.02,61.7,1805.33,1032.49,772.84,-20.98,#2006-05-21#,0,0
    184.2,64.43,1183.07,732.38,450.69,-2.68,#2006-05-22#,0,0
    272.79,58.21,1063.2,658.03,405.17,-9.92,#2006-05-23#,0,0
    218.37,65.84,1057.07,660.77,396.3,-.09,#2006-05-24#,0,0
    316.04,69,1313.73,801.14,512.59,1.06,#2006-05-25#,0,0
    441.96,67.07,1801.83,1016,785.83,.05,#2006-05-26#,0,0
    261.37,66.25,2481.11,1486.95,994.16,3.07,#2006-05-27#,0,0
    145.13,67.15,2599.5,1445.2,1154.3,-39.14,#2006-05-28#,0,0
    352.61,66.2,2829.92,1484.49,1345.43,3.01,#2006-05-29#,0,0
    319.93,62.65,1481.31,873.96,607.35,-15.2,#2006-05-30#,0,0
    271.54,70.49,1302.39,800.4,501.99,-1.79,#2006-05-31#,0,0
    348.65,63.15,1221.78,680.25,541.53,-11.51,#2006-06-01#,0,0
    268.41,64.75,1664.62,913.64,750.98,-19.44,#2006-06-02#,0,0
    183.18,67.45,1878.53,1060.25,818.28,-14.73,#2006-06-03#,0,0
    234.52,62.85,1974.76,965.35,1009.41,.74,#2006-06-04#,0,0
    194.41,63.68,1034.18,664.94,369.24,-10.46,#2006-06-05#,0,0
    281.55,69.5,1203.39,701.78,501.61,5.74,#2006-06-06#,0,0
    238.63,65.64,1217.29,750.03,467.26,-8.77,#2006-06-07#,0,0
    334.92,75.2,1239.12,732.24,506.88,-23.5,#2006-06-08#,0,0
    287.96,73.48,929.15,618.09,311.06,-4.48,#2006-06-09#,0,0
    259.5,58.73,1092.12,698.07,394.05,-.22,#2006-06-10#,0,0
    293.06,56.27,1870.39,956.97,913.42,-1.08,#2006-06-11#,0,0
    230.15,68.07,1206.63,792.31,414.32,-3.93,#2006-06-12#,0,0
    304.31,66.54,1398.28,742.89,655.39,2.12,#2006-06-13#,0,0
    272.15,75.12,1113.83,702.36,411.47,1.56,#2006-06-14#,0,0
    350,63.14,1274.59,691.54,583.05,-22.67,#2006-06-15#,0,0
    370.02,66.73,1549.91,928.84,621.07,-.11,#2006-06-16#,0,0
    346.7,66.95,1323.96,764.15,559.81,-3.96,#2006-06-17#,0,0
    231.55,60.22,2756.85,1548.14,1208.71,-4.31,#2006-06-18#,0,0
    290.85,79.05,1224.62,706.77,517.85,-28.1,#2006-06-19#,0,0
    245.81,70.27,1509.17,881.86,627.31,-8.07,#2006-06-20#,0,0
    331.27,58.92,1349.04,735.13,613.91,-.75,#2006-06-21#,0,0
    256.62,70.39,1561.29,940.47,620.82,3.36,#2006-06-22#,0,0
    351.41,69.3,1380.97,689.76,691.21,-11.23,#2006-06-23#,0,0
    280.9,68.65,1381.73,844.51,537.22,-4.54,#2006-06-24#,0,0
    192.85,72.18,2329.85,1242.17,1087.68,-1.37,#2006-06-25#,0,0
    293.9,65.69,982.2,605.44,376.76,-1.98,#2006-06-26#,0,0
    218.15,55.15,1407.98,895.76,512.22,-2.71,#2006-06-27#,0,0
    185.74,59.74,1149.96,727.41,422.55,-.33,#2006-06-28#,0,0
    245.38,69.23,1321.02,661.86,659.16,0,#2006-06-29#,0,0
    391.2,65.76,1912.91,844.36,1068.55,-16.66,#2006-06-30#,0,0
    370.52,68.75,1673.38,842.23,831.15,-5.42,#2006-07-01#,0,0
    429.57,74.7,2309.02,1147.45,1161.57,-4.71,#2006-07-02#,0,0
    292.15,64.8,1979.37,1127.75,851.62,-7.68,#2006-07-03#,0,0
    211.72,66.4,2021.69,1025.88,995.81,-1.55,#2006-07-04#,0,0
    306.56,65.56,1178.73,726.72,452.01,.23,#2006-07-05#,0,0
    223.45,73.58,1590.3,947.27,643.03,-3.35,#2006-07-06#,0,0
    351.5,73.48,1449.05,797.93,651.12,-4.16,#2006-07-07#,0,0
    265.61,76.94,1754.1,935.54,818.56,8.2,#2006-07-08#,0,0
    290.62,63.84,2111.24,1022.94,1088.3,-11.87,#2006-07-09#,0,0
    243.17,69.18,1193.01,698.27,494.74,-.96,#2006-07-10#,0,0
    311.58,64.71,1316.84,753.25,563.59,-1.32,#2006-07-11#,0,0
    237.41,72.76,1725.64,987.02,738.62,.37,#2006-07-12#,0,0
    197.65,69.53,1019.48,638.3,381.18,-10.35,#2006-07-13#,0,0
    289.28,73.98,1739.16,932.55,806.61,-.01,#2006-07-14#,0,0
    215.74,60.27,2092.55,1075.12,1017.43,-13.37,#2006-07-15#,0,0
    246.86,67.9,2087.52,1200.73,886.79,.35,#2006-07-16#,0,0
    301.23,65.03,906.85,445.3,461.55,-13.09,#2006-07-17#,0,0
    255.53,67.51,1134.41,725.9,408.51,14.48,#2006-07-18#,0,0
    198.55,65.73,1254.87,791.59,463.28,-1.11,#2006-07-19#,0,0
    281.83,64.87,1113.84,628.77,485.07,-2.82,#2006-07-20#,0,0
    304.44,60.35,1426.38,822.37,604.01,-.74,#2006-07-21#,0,0
    240.21,69.63,1548.1,908.67,639.43,-.13,#2006-07-22#,0,0
    277.88,75.84,2180.26,1131.53,1048.73,11.37,#2006-07-23#,0,0
    204.75,70.89,1246.82,668.29,578.53,-13.2,#2006-07-24#,0,0
    280.74,62.33,1065.17,601.66,463.51,.41,#2006-07-25#,0,0
    240.88,66.75,1697.78,976.44,721.34,13.26,#2006-07-26#,0,0
    178.17,69.68,1490.91,845.54,645.37,-.91,#2006-07-27#,0,0
    333.06,61.1,1691.56,907.29,784.27,-.76,#2006-07-28#,0,0
    246.99,58.06,1902.74,1068.96,833.78,.91,#2006-07-29#,0,0
    295.46,74.22,2198.44,1132.47,1065.97,5.15,#2006-07-30#,0,0
    243.26,78.21,1289.53,751.52,538.01,-4.07,#2006-07-31#,0,0
    218.61,62.7,862.65,493.99,368.66,-10.16,#2006-08-01#,0,0
    343.78,70.65,995.31,563.04,432.27,-.6,#2006-08-02#,0,0
    304.23,69.27,1278.17,773.07,505.1,-6.56,#2006-08-03#,0,0
    250.35,76.48,1472.55,818.84,653.71,.19,#2006-08-04#,0,0
    195.47,68.75,1745.74,1002,743.74,-1.04,#2006-08-05#,0,0
    240.73,68.31,2045.32,1136.23,909.09,2.47,#2006-08-06#,0,0
    190.75,66.38,1192,759.9,432.1,.49,#2006-08-07#,0,0
    180.42,64.13,1011.71,596.9,414.81,-11.63,#2006-08-08#,0,0
    268.9,73.03,887.74,499.2,388.54,.96,#2006-08-09#,0,0
    337.8,58.66,1441.12,737.98,703.14,-3.06,#2006-08-10#,0,0
    375.54,69.67,1239.59,676.14,563.45,-2.43,#2006-08-11#,0,0
    266.73,50.71,1505.67,952.25,553.42,-1.29,#2006-08-12#,0,0
    206.7,70.58,1433.11,868.8,564.31,-1.87,#2006-08-13#,0,0
    289,75.02,787.1,422.28,364.82,-6.95,#2006-08-14#,0,0
    263.96,71.33,1037.85,621.82,416.03,-.11,#2006-08-15#,0,0
    237.26,67.01,943.65,573.13,370.52,.32,#2006-08-16#,0,0
    205.87,72.32,844.23,603.84,240.39,.44,#2006-08-17#,0,0
    297.03,71.52,795.29,451,344.29,-.79,#2006-08-18#,17.39,777.9
    229.58,61.25,1326.58,810.42,516.16,1.23,#2006-08-19#,50.81,1275.77
    283.83,60.92,1898.68,990.76,907.92,-6.01,#2006-08-20#,52.62,1846.06
    233.99,72.5,949.27,577.16,372.11,-.97,#2006-08-21#,48.6,900.67
    194.57,63.65,1013.29,628.14,385.15,-5.35,#2006-08-22#,20.76,992.53
    288.81,73.84,689.66,395.01,294.65,-2.24,#2006-08-23#,12.62,677.04
    270.05,57.96,723.65,376.41,347.24,1.44,#2006-08-24#,15.79,707.86
    364.69,65.92,1067.47,606.57,460.9,1.85,#2006-08-25#,27.81,1039.66
    299.81,62.45,1348.95,822.52,526.43,7.26,#2006-08-26#,70.88,1278.07
    223.24,64.69,1777.99,1031.18,746.81,-12.88,#2006-08-27#,44.09,1733.9
    191.75,80.01,618.48,476.87,141.61,-4.9,#2006-08-28#,40.64,577.84
    169.7,63.36,953.51,623.96,329.55,-3.87,#2006-08-29#,47.7,905.81
    278.47,69.3,660.56,375.85,284.71,-6,#2006-08-30#,9.34,651.22
    238.61,49.47,1075.88,642.62,433.26,-.11,#2006-08-31#,6.05,1069.83
    331.66,65.61,959.64,528.62,431.02,.24,#2006-09-01#,110.18,849.46
    292.9,62.94,837.55,649.36,188.19,.58,#2006-09-02#,11.76,825.79
    252.1,66.35,1125.26,676.18,449.08,-.1,#2006-09-03#,38.97,1086.29
    184,66.45,1669.83,929.72,740.11,-7.7,#2006-09-04#,0,1669.83
    179.91,70.07,712.35,418.22,294.13,-.96,#2006-09-05#,12.29,700.06
    255.03,59.7,500.93,310.99,189.94,-7.05,#2006-09-06#,10.3,490.63
    231.81,67.72,739.93,457.86,282.07,-7.1,#2006-09-07#,0,739.93
    290.08,53.73,510.24,222.57,287.67,.08,#2006-09-08#,29.07,481.17
    256.45,71.64,770.61,464.55,306.06,-4.57,#2006-09-09#,29.37,741.24
    220.82,71.07,682.18,457.42,224.76,-1.37,#2006-09-10#,37.39,644.79
    212.35,64.63,617.18,515.36,101.82,-.27,#2006-09-11#,0,617.18
    179.95,70.13,787.12,572.12,215,-.87,#2006-09-12#,18.6,768.52
    286.9,61.86,531.25,337.03,194.22,-.24,#2006-09-13#,24.76,506.49
    247.93,55.69,867.8,583.8,284,-3.89,#2006-09-14#,12,855.8
    215.06,60.22,823.44,651.99,171.45,.86,#2006-09-15#,3.5,819.94
    185.74,73.81,779.92,490.86,289.06,.89,#2006-09-16#,67.83,712.09
    151.56,71.82,799.25,486.93,312.32,-1.34,#2006-09-17#,20.59,778.66
    282.16,64.94,267.76,202.76,65,.35,#2006-09-18#,26.6,241.16
    260.9,64.94,330.75,330.75,0,.67,#2006-09-19#,23.7,307.05
    251.08,66.38,522.04,438.43,83.61,-2.86,#2006-09-20#,29.98,492.06
    232.05,38.07,385.2,305.2,80,-.84,#2006-09-21#,26.58,358.62
    210.25,48.42,545.72,460.34,85.38,4.69,#2006-09-22#,10.19,535.53
    183.95,70.16,574.27,374.67,199.6,-.88,#2006-09-23#,33.23,541.04
    151.55,60.53,1159.05,731.02,428.03,-1.34,#2006-09-24#,38.47,1120.58
    267.95,65.98,348.21,293.23,54.98,2.19,#2006-09-25#,17.92,330.29
    243.09,70.13,659.23,532.65,126.58,-2.3,#2006-09-26#,9.02,650.21
    240.01,64.75,660.09,477.22,182.87,-.21,#2006-09-27#,70.29,589.8
    226.39,65.39,510.96,470.96,40,-.67,#2006-09-28#,24.04,486.92
    207.7,64,666.18,471.34,194.84,-.45,#2006-09-29#,49.34,616.84
    209.51,63.44,1089.12,702.16,386.96,-.76,#2006-09-30#,138.86,950.26
    243.97,67.4,1686.72,1045.3,641.42,-3.1,#2006-10-01#,89.48,1597.24
    218.56,67.4,746.64,746.64,0,-2.89,#2006-10-02#,11.33,735.31
    189.64,67.4,629.32,629.32,0,-2.85,#2006-10-03#,9.77,619.55
    189.8,53.27,924.81,614.65,310.16,.08,#2006-10-04#,27.4,897.41
    178.06,54.8,835.04,609.55,225.49,-.77,#2006-10-05#,84.6,750.44
    281.28,71.76,637.54,577.54,60,.26,#2006-10-06#,71.64,565.9
    229.37,55.31,1210.45,900.45,310,.51,#2006-10-07#,42.77,1167.68
    184.47,70.46,1143.59,751,392.59,-14.12,#2006-10-08#,39.64,1103.95
    175.43,68.76,542.34,522.34,20,-1.99,#2006-10-09#,18,524.34
    155.2,59.06,622,558.23,63.77,-1.55,#2006-10-10#,5.52,616.48
    193.29,59.06,413.59,413.59,0,-4.75,#2006-10-11#,14.51,399.08
    183.04,59.06,432.76,432.76,0,-.85,#2006-10-12#,63.47,369.29
    152.2,51.15,535.1,482.35,52.75,.54,#2006-10-13#,40.05,495.05
    135.76,76.12,845.3,737.22,108.08,-.67,#2006-10-14#,51.83,793.47
    68.93,42.4,1852.57,1171.71,680.86,17.99,#2006-10-15#,141.24,1711.33
    87.88,42.4,608.1,608.1,0,3.21,#2007-03-04#,0,608.1
    200.71,42.4,292.78,292.78,0,-4.73,#2007-03-05#,0,292.78
    181.78,42.4,414.19,414.19,0,-.75,#2007-03-06#,7.43,406.76
    162.48,42.4,473.49,473.49,0,.9,#2007-03-07#,21.35,452.14
    141.27,42.4,568.18,568.18,0,-3.13,#2007-03-08#,31.06,537.12
    239.55,58.89,731.3,581.95,149.35,5.46,#2007-03-09#,28,703.3
    208.41,60.1,945.73,631.5,314.23,-2.2,#2007-03-10#,28.23,917.5
    172.18,64.84,1149.33,710.23,439.1,-2.87,#2007-03-11#,30.12,1119.21
    213.45,61.88,766.32,696.32,70,-3.81,#2007-03-12#,26.63,739.69
    195.18,61.77,770.62,586.68,183.94,-.13,#2007-03-13#,26.94,743.68
    293.24,66.25,667.41,520.82,146.59,-.53,#2007-03-14#,66.03,601.38
    257.75,59.53,705.64,526.67,178.97,.4,#2007-03-15#,55.08,650.56
    327.5,53.22,822.64,506.53,316.11,1.55,#2007-03-16#,50.86,771.78
    278.21,64.86,994.33,741.09,253.24,.06,#2007-03-17#,68.25,926.08
    230.54,61.84,901.51,649.5,252.01,-.21,#2007-03-18#,33.06,868.45
    198.77,61.15,612.85,464.98,147.87,.49,#2007-03-19#,22.98,589.87
    174.97,62.9,534.99,469.9,65.09,-.86,#2007-03-20#,6.16,528.83
    242.48,68.83,540,390.24,149.76,.46,#2007-03-21#,39.08,500.92
    260.35,67.76,793.51,623.58,169.93,-.32,#2007-03-22#,36.45,757.06
    324.39,64.01,1186.7,671.55,515.15,1.36,#2007-03-23#,59.81,1126.89
    224.6,62.42,1361.84,866,495.84,-1.99,#2007-03-24#,43.5,1318.34
    274.83,70.85,1677.62,1049.11,628.51,-1.07,#2007-03-25#,110.89,1566.73
    204.05,75.01,1320.93,889.86,431.07,5.95,#2007-03-26#,69.99,1250.94
    167.14,67.59,1015.25,660.22,355.03,-.31,#2007-03-27#,49.85,965.4
    275.21,63.38,844.15,455.38,388.77,-1.08,#2007-03-28#,40.95,803.2
    229.7,71.82,918.69,662.24,256.45,-2.53,#2007-03-29#,110.82,807.87
    346.97,65.32,728.62,561.58,167.04,13.4,#2007-03-30#,85.37,643.25
    320.15,57.68,804.91,629.34,175.57,-7.71,#2007-03-31#,58.03,746.88
    260.1,69.64,955.24,700.52,254.72,.2,#2007-04-01#,24.61,930.63
    251.09,64.04,669,499.92,169.08,-.15,#2007-04-02#,54.54,614.46
    229.6,64.04,350.96,350.96,0,-1.15,#2007-04-03#,9.87,341.09
    197.19,72.67,541.49,485.15,56.34,-.67,#2007-04-04#,13.16,528.33
    321.29,60.08,524.19,323.82,200.37,-.3,#2007-04-05#,7.44,516.75
    300.36,80.06,772.18,569.43,202.75,.33,#2007-04-06#,29.87,742.31
    280.31,70.82,931.33,710.39,220.94,-.1,#2007-04-07#,78.85,852.48
    190.83,66.1,931.26,717.12,214.14,-.9,#2007-04-08#,38.21,893.05
    161.76,63.55,829.39,637.48,191.91,-.17,#2007-04-09#,36.96,792.43
    142.27,49.44,574.03,507.12,66.91,-.61,#2007-04-10#,17.31,556.72
    261.61,64.55,306.41,188.67,117.74,-.16,#2007-04-11#,3.72,302.69
    235.19,73.63,729.41,509.43,219.98,-1.38,#2007-04-12#,41,688.41
    324.64,68.62,962.66,638.85,323.81,-6.96,#2007-04-13#,116.01,846.65
    273.92,74.64,1489.82,859.74,630.08,-3.44,#2007-04-14#,130.08,1359.74
    317.39,62.44,1816.31,913.74,902.57,.16,#2007-04-15#,74.14,1742.17
    267.48,68.81,1141.14,760.83,380.31,-3.26,#2007-04-16#,50.62,1090.52
    214.28,71.9,1074.37,757.08,317.29,-.55,#2007-04-17#,51.36,1023.01
    302.25,55.67,1031.62,677.94,353.68,1.49,#2007-04-18#,88.31,943.31
    260.47,54.88,1224.9,871.89,353.01,.42,#2007-04-19#,73.6,1151.3
    346.5,66.32,1097.43,709.15,388.28,-1.05,#2007-04-20#,57.33,1040.1
    293.86,66.41,1323.77,875.83,447.94,-5.42,#2007-04-21#,119.81,1203.96
    236.7,60.1,1173.23,764.6,408.63,-1.02,#2007-04-22#,59.34,1113.89
    200.71,67.32,907.03,650.63,256.4,-1.83,#2007-04-23#,26.97,880.06
    334.62,63.76,796.15,499.6,296.55,-2.1,#2007-04-24#,40.12,756.03
    276.82,61.88,1053.73,753.45,300.28,-9.7,#2007-04-25#,55.8,997.93
    211.28,68.34,1482.25,933.75,548.5,.23,#2007-04-26#,82.25,1400
    282.5,74.28,1384.16,816.11,568.05,-7.45,#2007-04-27#,76.12,1308.04
    167.48,76.68,1928.53,1187.5,741.03,-1.13,#2007-04-28#,80.88,1847.65
    233.78,66.63,2091.47,1137.15,954.32,.69,#2007-04-29#,133.29,1958.18
    189.56,53.57,975.33,684.25,291.08,8.27,#2007-04-30#,73.82,901.51
    282.5,67.63,1020.96,681.5,339.46,-1.84,#2007-05-01#,72.78,948.18
    250.1,57.42,1127.2,749.83,377.37,1.34,#2007-05-02#,48.02,1079.18
    337.75,56.81,984.9,660.24,324.66,.76,#2007-05-03#,58.23,926.67
    290.04,71.8,947.91,647.32,300.59,.43,#2007-05-04#,63.18,884.73
    255.79,61.92,1277.11,878.68,398.43,-3.21,#2007-05-05#,48.78,1228.33
    199.94,67.26,1612.57,931.84,680.73,.07,#2007-05-06#,74.07,1538.5
    288.63,75.14,779.05,592.28,186.77,-5.51,#2007-05-07#,36.08,742.97
    270.19,63.86,983.15,733.24,249.91,-.71,#2007-05-08#,68.92,914.23
    207.86,71.28,1682.63,1110.79,571.84,-.28,#2007-05-09#,59.41,1623.22
    271.32,63.48,1424.6,821.88,602.72,-1.29,#2007-05-10#,90.22,1334.38
    387.51,67.68,1705.66,1033.79,671.87,-13.78,#2007-05-11#,135.65,1570.01
    304.66,76.51,1878.78,1175.55,703.23,-5.8,#2007-05-12#,170.74,1708.04
    185.02,74.53,2928.87,1564.39,1364.48,15.99,#2007-05-13#,104.17,2824.7
    176.51,64.07,1008.85,647.05,361.8,-8.38,#2007-05-14#,83.36,925.49
    284.75,70.8,826.92,541.32,285.6,13.95,#2007-05-15#,103.14,723.78
    239.59,71.58,1254.89,930.87,324.02,.98,#2007-05-16#,335.82,919.07
    205.52,69.82,1153.5,725.52,427.98,-.32,#2007-05-17#,60.65,1092.85
    377.9,58.91,1280.23,775.4,504.83,3.08,#2007-05-18#,57.53,1222.7
    236.77,67.47,2319.36,1403.32,916.04,-1.09,#2007-05-19#,138.82,2180.54
    300.86,71.07,1452.14,806.15,645.99,-11.5,#2007-05-20#,104.69,1347.45
    268.26,53.35,1085.11,680.48,404.63,.54,#2007-05-21#,139.18,945.93
    216.8,58.1,1029.06,734.58,294.48,-5.8,#2007-05-22#,55.18,973.88
    293.61,72.8,941.57,611.13,330.44,-9.25,#2007-05-23#,122.75,818.82
    273.86,51.7,939.69,672.66,267.03,4.1,#2007-05-24#,72.2,867.49
    405.32,62.11,1559.13,775.73,783.4,-4.24,#2007-05-25#,61.33,1497.8
    347.54,77.91,1345.17,789.82,555.35,-.75,#2007-05-26#,129.77,1215.4
    266.12,71.82,2216.29,1302.01,914.28,-.71,#2007-05-27#,178.42,2037.87
    290.28,76.05,2523.11,1355.63,1167.48,-5.99,#2007-05-28#,195.93,2327.18
    289.02,53.3,941.22,578.68,362.54,1.15,#2007-05-29#,57.11,884.11
    259.17,68.65,1129.88,789.69,340.19,-15.14,#2007-05-30#,147.58,982.3
    209.23,55.4,1444.7,972.22,472.48,.67,#2007-05-31#,131.72,1312.98
    292.25,63.35,1212.93,813.41,399.52,1.35,#2007-06-01#,132.15,1080.78
    223.32,60.23,1618.82,946.1,672.72,-9.17,#2007-06-02#,81.75,1537.07
    270.97,61.96,1971.52,1114,857.52,-4.13,#2007-06-03#,81.26,1890.26
    238.23,65.89,900.99,668.75,232.24,-4.61,#2007-06-04#,50.43,850.56
    200.07,59.33,1159.2,710.72,448.48,-11.25,#2007-06-05#,47.85,1111.35
    314.41,62.8,883.38,582.04,301.34,-34.6,#2007-06-06#,90.76,792.62
    255.56,60.5,1139.51,800.67,338.84,-16.15,#2007-06-07#,64.82,1074.69
    325.47,69.1,1310.44,840.23,470.21,-6.67,#2007-06-08#,140.80,1310.44
    260.37,64.15,1652.4,1012.29,640.11,-.4,#2007-06-09#,148.76,1503.64
    [/vba]


  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi,
    Welcome to VBAX.
    I tried you code and couldn't find a problem. Can you zip and post your txt file?. Use Manage Attachments in the Go Advanced section.

    BTW, Here's a refinement of your code which runs a bit quicker
    [vba]
    Option Explicit
    Sub SumMonth()
    Dim Starting1() As Double
    Dim Starting2() As Double
    Dim Bank() As Double
    Dim Side1Bank() As Double
    Dim Side2Bank() As Double
    Dim diff() As Double
    Dim dates() As Date
    Dim ccard() As Double
    Dim cash() As Double
    Dim totalSide1 As Double
    Dim totalSide2 As Double
    Dim totalBank As Double
    Dim totaldiff As Double
    Dim totalccard As Double
    Dim totalcash As Double
    Dim months As Date

    totalSide1 = 0
    totalSide2 = 0
    totalBank = 0
    totaldiff = 0
    totalccard = 0
    totalcash = 0
    months = InputBox("enter the month, the 1st of the month, and then the year (ex. 07/01/2005)")
    Open "C:\Documents and Settings\All Users\Documents\tills\Till_Data.txt" For Input As #1

    Dim counter As Integer
    counter = 0
    Dim temp, temp1, temp2, temp3, temp4, temp5, temp7, temp8 As Double
    Dim temp6 As String
    Do While Not EOF(1)
    counter = counter + 1
    Input #1, temp, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8
    Loop
    Close #1
    ReDim Starting1(counter + 1) As Double
    ReDim Starting2(counter + 1) As Double
    ReDim Bank(counter + 1) As Double
    ReDim Side1Bank(counter + 1) As Double
    ReDim Side2Bank(counter + 1) As Double
    ReDim diff(counter + 1) As Double
    ReDim dates(counter + 1) As Date
    ReDim ccard(counter + 1) As Double
    ReDim cash(counter + 1) As Double
    Dim i As Integer
    Dim j As Integer

    Range("A1:G" & counter + 5).ClearContents
    Open "C:\Documents and Settings\All Users\Documents\tills\Till_Data.txt" For Input As #1

    For i = 1 To counter
    Input #1, Starting1(i), Starting2(i), Bank(i), Side1Bank(i), Side2Bank(i), diff(i), dates(i), ccard(i), cash(i)
    Next i
    Close #1
    Range("A1").Resize(1, 7) = Array("Date", "Bank Side 1", "Bank Side 2", "Bank Total", "difference", _
    "Credit Card", "Cash Deposited")
    With Range("A1")
    For i = 1 To counter
    If (Month(dates(i)) = Month(months)) Then
    If (Year(dates(i)) = Year(months)) Then
    j = j + 1
    .Offset(j, 0) = dates(i)
    .Offset(j, 1) = Side1Bank(i)
    totalSide1 = totalSide1 + Side1Bank(i)
    .Offset(j, 2) = Side2Bank(i)
    totalSide2 = totalSide2 + Side2Bank(i)
    .Offset(j, 3) = Bank(i)
    totalBank = totalBank + Bank(i)
    .Offset(j, 4) = diff(i)
    totaldiff = totaldiff + diff(i)
    .Offset(j, 5) = ccard(i)
    totalccard = totalccard + ccard(i)
    .Offset(j, 6) = cash(i)
    totalcash = totalcash + cash(i)
    End If
    End If
    Next i
    j = j + 2
    .Offset(j, 1) = totalSide1
    .Offset(j, 2) = totalSide2
    .Offset(j, 3) = totalBank
    .Offset(j, 4) = totaldiff
    .Offset(j, 5) = totalccard
    .Offset(j, 6) = totalcash
    End With
    End Sub

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    well i figured out what the problem was... but thanks anyway, it turns out that my data sheet had like 1 or 2 blank lines at the end, seems obvious now but i was way over thinking this one

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I suspected something like that!
    Glad you have it fixed. Do you need a solution to handle that possibility?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •