我有這個代碼
Sub ifcitythencity()
If InStr(1, (range("A2").Value), "San Francisco") > 0 Then range.Value("B2") = "San Francisco"
End Sub
但是當我運行偵錯器時,我收到錯誤“編譯錯誤:參數不可選”,並且它突出顯示第二個“範圍”。是什麼導致了這個錯誤?
答案1
你正在使用range.value("B2")
而不是range("B2").value
-
Sub ifcitythencity()
If InStr(1, (range("A2").Value), "San Francisco") > 0 Then range("B2").Value = "San Francisco"
End Sub
錯誤
參數不是可選的
為您提供問題的線索 -range(arg)
目的 不得不內有爭論()
。