我在以下代码中收到1004错误,我不确定原因。
Public Function SetFormulaAndPasteVals(in_range As Range, formula_str As String, start_row As Long, end_row As Long)
Dim start_cell As Range
Dim in_col As Long
in_col = in_range.Column
' This is where I get the error
Set start_cell = in_range.Range("R" & start_row & "C" & in_col)
start_cell.Formula = formula_str
If start_row < end_row Then
start_cell.Copy Destination:=in_range.Range("R" & start_row + 1 & "C" & in_col & ":R" & end_row & "C" & in_col)
Else
start_cell.Copy Destination:=in_range.Range("R" & start_row - 1 & in_col & "C" & in_col & ":R" & end_row & "C" & in_col)
End If
Call CopyPasteValues(in_range)
Application.CutCopyMode = False
End Function
如果可能的话,我试图避免引用专栏信。我不明白为什么它不喜欢这里的范围函数中的R1C1参考。