我定义了这个功能:
var_sup <- function(var1,var2)
{
df$RD <- ifelse(df[var1]>df[var2],1,0)
df$RD <- as.numeric(df$RD)
return(df)
}
我想在excel中使用它(使用Bert Package):
Sub compare()
Dim v As Variant
Dim var1 As String
Dim var2 As String
With Worksheets("Parametre")
var1 = .Cells(19, 1).Value
var2 = .Cells(19, 3).Value
End With
Sheets.Add.Name = "test"
v = Application.Run("BERT.Call", "var_sup", "var1", "var2")
ActiveSheet.Range("A1:K130000").Value = v
End Sub
我创建了.Cells(19,1)的值。带
的值Sub ItsOK()
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="var1,var2,var3"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
但是当我尝试运行宏比较时,我遇到以下错误:
谢谢你!
[.data.frame
中的错误(df,&#34; var1&#34;):在中选择的未定义列 bert console!