我正在尝试将公式放入包含VBA变量的单元格中,但我得到另一个Application or Object defined error
。错误是在第一行op Range("R" & i).FormulaR1C1 = "=Q" & i & "/" & DollarRate
上触发的。我尝试仅使用Formula
代替FormulaR1C1
。
列Q和R为空。列Q将包含以€为单位的值,而列R将以$。
显示值Dim LastRow As Integer, i As Integer
Dim DollarRate As Double
DollarRate = InputBox("Enter dollar rate:", "Dollar rate")
Range("Q1").Value = "$ POS"
Range("R1").Value = "€ POS"
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To LastRow
Range("R" & i).FormulaR1C1 = "=Q" & i & "/" & DollarRate
Next i
答案 0 :(得分:1)
尝试替换它:
For i = 2 To LastRow
Range("R" & i).FormulaR1C1 = "=Q" & i & "/" & DollarRate
Next i
用这个:
Range("R2:R" & lastrow).FormulaLocal = "=Q2/" & DollarRate