1

您好,我有一些代码用于选择最接近用户值的值,即

Private Sub CommandButton1_Click() 
Dim col As Integer 
col = Me.TextBox1.Value
ActiveCell.FormulaR1C1 = "=SMALL($A$1:$EN$1,COUNTIF($A$1:$EN$1,""<" & col & """)+1)"
End Sub 

但我收到 RUNTIME ERROR 1004 任何人请帮帮我

4

1 回答 1

3

您调用 R1C1 样式公式属性,但提供 A1 样式公式。试试这个:

ActiveCell.Formula = "=SMALL($A$1:$EN$1,COUNTIF($A$1:$EN$1,""<" & col & """)+1)"

ActiveCell.Formula代替ActiveCell.FormulaR1C1.

于 2012-10-22T11:26:42.917 回答