-1

I am working n a program where I need to store 4 individual values in one column and take the sum of 12 different columns so that I can have 4 totals over the past 12 months. The problem that I am running into is that I keep getting TYPE MISMATCH erro 13.

Sub MTBMtotals()

Sheets(8).calculate

meantot = 0
ansitot = 0
apitot = 0
othertot = 0

currmonth = Month("7/22/2013")
curryear = Year("7/22/2013")


Column = currmonth + 2
Row = (curryear - 2012) * 16 + 3

For i = 1 To 12
If Row = 2 Then
Column = 14
Row = Row - 16
End If


meantot = meantotal + Sheets(8).Cells(Row, Column)
ansitot = ansitot + Sheets(8).Cells(Row + 1, Column)
apitot = apitot + Sheets(8).Cells(Row + 2, Column)
othertot = othertot + Sheets(8).Cells(Row + 3, Column)  **<------- Error:13**

Column = Column - 1
Next

Sheets(8).Cells(3, 18) = meantotal
Sheets(8).Cells(4, 18) = ansitot
Sheets(8).Cells(5, 18) = apitot
Sheets(8).Cells(6, 18) = othertot


End Sub

Thank you, any help is good help.

4

1 回答 1

0

也许您可以为我们提供一个示例表?顺便说一句,使用 =SUM(Cell:Cell) 公式然后复制结果或引用该单元格不是更容易吗?不确定是否需要宏。

于 2013-07-23T06:39:27.903 回答