【发布时间】:2018-02-18 23:04:19
【问题描述】:
请提供一些帮助 - 尽量保持简单
我有一个用户窗体,它根据 ComboBox 中的选择更新文本框。我希望能够更改这些填充的框,然后使用更新命令,更改工作表中的值,然后清除表单
我已经能够创建添加数据的用户窗体,但我很难让 VBA 从控制框中选择活动单元格和活动行...????
一旦我可以将 VBA 放入正确的 AvtiveCell,我就可以根据需要使用偏移量和更改/添加
Private Sub ComboBox1_Change()
With Me
.TextBox1.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 2)
.TextBox2.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 3)
.TextBox3.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 4)
.TextBox4.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 5)
.TextBox5.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 6)
.TextBox6.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 7)
.TextBox7.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 8)
.TextBox8.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 9)
.TextBox9.Value = Sheet1.Cells(.ComboBox1.ListIndex + 2, 10)
End With
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub EditAddButton_Click()
EditAdd
End Sub
Private Sub UserForm_Initialize()
TextBox1.SetFocus
End Sub
【问题讨论】:
-
你能粘贴你当前的用户表单代码吗?我们需要看看你已经走了多远。
-
嗨,克里斯,代码如下