【发布时间】:2016-12-06 23:00:23
【问题描述】:
我正在尝试使用 VBA 将计算添加到多个工作表的使用范围。问题是,我一直收到这个错误
'类型不匹配'
在线阅读ws.Cells(countie, 12).FormulaR1C1 =...
这是我的语法 - 什么会解决这个问题以便执行此语法?
Function JunctionTest()
Dim ws As Worksheet, countie As Long
For Each ws In ActiveWorkbook.Worksheets
With ws
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
LastRow = .Cells.Find(What:="*",After:=.Range("A1"),LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows,SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
LastRow = 1
End If
For countie = 1 To LastRow
ws.Cells(countie, 12).FormulaR1C1 = "=RC7+RC8" / "=VLookup(A2, Totals!B2:R100, 3, False)"
Next countie
End Function
编辑 --
【问题讨论】:
-
看起来你试图错误地使用工作表形式 - 不过我可能是错的
标签: vba excel excel-2013 worksheet-function