此代码检索已过滤数据的数量 - RelCov。然后计算"魔杖的数量"在那组RelCov中。 R1C1公式比较上周RelCov的周数,并将差异返回为"?更多","?less"或"与上周相同"然后我会在该公式的末尾添加一些" wands"这是RelCov。每当我包括&公式中的魔杖,我得到一个" NAME"错误。这就是我所拥有的:
Windows("usertemp.xls").Activate
Sheets("Sheet1").Select
Dim RelCov As Integer
RelCov = Application.CountIf(Range("ah:ah"), "Relevant Covered")
ActiveSheet.Range("$A$1:$AO$18690").AutoFilter Field:=34, Criteria1:="Relevant Covered"
Dim wands As Integer
wands = Application.CountIf(Range("b:b"), "WAND*")
' MsgBox wands
Windows("User File Analysis test.xlsm").Activate
Sheets("Sheet1").Select
Range("ReleventCovered").Select
ActiveCell = RelCov '& Chr(10) & wands & " wands"
ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Activate
ActiveCell.FormulaR1C1 = "=if(rc[-1]<r[-1]c[-1],r[-1]c[-1]-rc[-1]&"" less"",if(rc[-1]>r[-1]c[-1],rc[-1]-r[-1]c[-1]&"" More"","" same as last week""))& "" wands = """
当我加入&amp;魔杖&amp;在&#34;&#34; Wands =&#34;&#34;在公式的最后,我得到一个名字&#34;错误。我如何包括&#34;魔杖&#34;在论坛结尾处变量并收到错误?
答案 0 :(得分:0)
你可以使用:
ActiveCell.FormulaR1C1 = "=CONCATENATE(IF(RC[-1]<R[-1]C[-1],R[-1]C[-1]-RC[-1] &"" less"", IF(RC[-1]>R[-1]C[-1],RC[-1]-R[-1]C[-1]&"" More"","" same as last week"")), "" wands = ""," & RelCov & ")"