我正在尝试复制某个范围内的IF
公式,但是和其他问题一样,我的问题出在双引号上。我目前有CHR(34)
表示我想要双引号,但是我的VBA错误是Expected end of line.
我需要它如何显示为公式:
=IF(D2=team,"",IF(D2=on," - Type1",IF(OR(D2=lr,D2=sn),"*"," - Type3")))
team, on, lr, sign
是引用字符串的变量。
Range()= "=IF(D2=" & team & ", "&Chr(34)&Chr(34)&",IF(D2=" & on & ","&Chr(34)&" - Type1"&Chr(34)&",IF(OR(D2=" &lr& ",D2=" &sn& "),"&Chr(34)&"*"&Chr(34)&","&Chr(34)&" - Type3"& Chr(34)&")))"
它在D2
语句的OR
的第二个实例中显示错误
答案 0 :(得分:0)
我相信以下代码应该可以正常工作,我只是将变量名从on
更改为oni
,因为我认为您不能拥有名为on
的变量我也用空格分隔&:
ActiveCell.Formula = "=IF(D2=" & team & ", " & Chr(34) & Chr(34) & ",IF(D2="" & oni & ""," & Chr(34) & " - Type1" & Chr(34) & ",IF(OR(D2=" & lr & ",D2=" & sn & ")," & Chr(34) & "*" & Chr(34) & "," & Chr(34) & " - Type3" & Chr(34) & ")))"