[英]Using string variables within a formula in VBA
我不明白為什么這段代碼行不通:
Cells(i, formula_col_index).Value = "=IF(" & time_location & "<>" & time_benchmark & ",""ERROR"",""OK"")"
哪里
time_location=" 17:00:00",
time_benchmark=" 17:30:00"
它不斷拋出應用程序定義的(或對象定義的)錯誤。
提前致謝。
由於您的變量time_location
和time_benchmark
包含字符串值,因此在使用公式時,應在雙引號中包括它們:
Cells(i, formula_col_index).Value = "=IF(""" & time_location & """<>""" & time_benchmark & """,""ERROR"",""OK"")"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.