2013-07-22 73 views
-1

我在工作na程序,我需要在一列中存储4个单独的值,并采取12个不同列的总和,以便我可以在过去12个月中总计4个。我遇到的问题是,我不断收到TYPE MISMATCH erro 13.Excel VBA帮助w /类型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 

谢谢,任何帮助是很好的帮助。

+0

您指定的单元格中有什么? – Stephan

+0

您是否定义了您使用过的变量? – Raystafarian

+0

我打赌它的日期格式 – 2013-07-22 18:23:01

回答

0

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