我在与模块 RunOB 相同的VBA项目中有一个用户窗体 DataInput 。这些位于Excel项目 Benchmarking.xlsx 中。我在 DataInput 窗体上有一个命令按钮,希望按该按钮在其中运行模块 RunOB 。另外,我正在将String参数从表单传递到模块。
replace_na
按钮单击方法为:
wl%>%
mutate_at(vars(starts_with('AB')),~`is.na<-`(.x,.x=='Y'))%>%
replace_na(set_names(as.list(names(.)),names(.)))
# A tibble: 4 x 5
x multi ABC ABD ABE
<chr> <chr> <chr> <chr> <chr>
1 1 Y "" "" ABE
2 2 Y ABC "" ABE
3 3 Y ABC "" ""
4 4 Y "" "" ABE
如果可能的话,如果我可以设置一个键盘快捷方式来打开 DataInput UserForm(在Excel项目中),那也会很有帮助。
答案 0 :(得分:0)
可以帮助您开发自己的代码的东西.........
'Public enum type to add a set of particular vbKeys to the standard key set
Public Enum typePressKeys
vbNoKey = 0
vbExitTrigger = -1
vbAnswerKey = 100
vbLaunchKey = 102
vbPrevious = 104
vbNext = 106
vbSpecialAccessKey = 108
End Enum
Public Sub OrganizeBenchmarks()
Dim stopLoop As Boolean, listOfYears As Variant, bidNum As String, name As String, state As String, year As String, category As String
'For example
listOfYears = Array(2017, 2018, 2019, 2020, 2021, 2022)
stopLoop = False
Load DataInputForm 'Assuming this is the name of your UserForm
With DataInputForm 'Assuming that this name would be an input control in your UserForm
.yearCB.List = listOfYears 'comboboxList control
.yearCB.ListIndex = 2
.Tag = vbNoKey
End With
DataInputForm.Show
Do
If DataInputForm.Tag = vbOK Then
'I have assumed you would use these names for input controls on your UserForm
bidNum = DataInputForm.bidNum_TextBox.Value
name = DataInputForm.name_TextBox.Value
state = DataInputForm.state_TextBox.Value
year = CStr(DataInputForm.yearCB.Value)
category = DataInputForm.category_TextBox.Value
Unload DataInputForm
stopLoop = True
ElseIf DataInputForm.Tag = vbCancel Then
Unload DataInputForm
Exit Sub
Else
stopLoop = False
End If
Loop Until stopLoop = True
'Place additional code here to take whatever actions
End Sub
答案 1 :(得分:0)
似乎很简单?
Private Sub CommandButton1_Click()
OrganizeBenchmarks "your", "arguments", "would", "go", "here"
End Sub