我有一个df,我导入它:
Sub ()
Dim Path As Variant
r = "df = read.csv('df')"
Application.Run "BERT.Exec", r
End Sub
我在Bert环境中有一些功能!
c_1 <- function (var1,var2) {
require(tidyverse)
var1 <- enquo(var1)
var2 <- enquo(var2)
df %>%
mutate(RG = ifelse(!!var1 > !!var2, 1, 0)) %>%
select(RG,ID)
}
c_2 <- function (var1,var2) {
require(tidyverse)
var1 <- enquo(var1)
var2 <- enquo(var2)
df %>%
mutate(RG = ifelse(!!var1 = !!var2, 1, 0)) %>%
select(RG,ID)
}
对于每个功能我
ID RG
1 1
2 0
3 1
然后我有一张表格excel&#34; Parametre&#34;那样:
我想根据下拉列表比较变量。 我想要多行
我尝试过这个宏,但它没有问题(我的表单测试中没有任何内容)。我希望每一个我都能在表格的一列中复制我的价值&#34; test&#34;
我希望每个人得到结果!并在列中复制。
Sub test()
Dim v As Variant
Dim var1 As Variant
Dim var2 As Variant
Sheets.Add.Name = "test"
With Worksheets("Parametre")
For i = 19 To 10
For j = 2 To 10 Step 2
If (Not IsEmpty(Range("A" & i))) Then
If (Range("B" & i) = ">") Then
var1 = .Cells(i, 1).Value
var2 = .Cells(i, 3).Value
v = Application.Run("BERT.Call", "c_1", var1, var2)
ActiveSheet.Columns(i).Select.Value = v
End If
If (Range("B" & i) = "=") Then
var1 = .Cells(i, 1).Value
var2 = .Cells(i, 3).Value
v = Application.Run("BERT.Call", "compare_inf", var1, var2)
ActiveSheet.Columns(i).Select.Value = v
End If
End If
Next j
Next i
End With
End Sub
最后我想在一张纸上试试&#34;
A B C
1 Id Rg_1 Rg_2
2 1 1 1
3 2 0 1