【发布时间】:2020-12-28 23:36:31
【问题描述】:
我正在尝试在 Excel VBA 中构建一个表单。我已经构建了表单,但我希望用户能够编辑表单中的数据。我希望用户能够输入参数,然后表单将搜索表格以查看参数是否存在。如果是,则表单将填充该行中的数据。
我不知道为什么这段代码有效,但我似乎无法将单元格中的数据取出。我可以从手表上看到正在选择正确的单元格。但是单元格不会分配给我的变量或组合框。这是我到目前为止所得到的!
Public Function LoadFormEdit(Row As Integer)
Dim rng As Range
Dim RowNum As Integer
RowNum = Row
Dim lookupValue As String
'Set the range to be the table we want to work with
Set rng = ThisWorkbook.Worksheets("MyWorksheet").Range("MyDataTable")
Dim ColOffset As Integer
ColOffset = rng.Column - 1
'Add the selections to the ComboBox, and make visible
Me.MyComboBox.Visible = True
lookupValue = rng.Cells(RowNum, 6).Text
Me.MyComboBox.value = lookupValue
非常感谢任何帮助!
【问题讨论】: