经过几个小时的努力解决这个问题,我希望有人可以让我理顺...
我正在尝试根据输入TextBox20的行号将Sheet1中的数据导入UserForm。
错误91:对象变量或未设置块变量
UserForm代码段:
Private Sub CommandButton9_Click()
Application.ScreenUpdating = False
Dim SelectRow As Range
Dim response As Integer
Dim UpdateForm As UserForm
Dim iRow As Integer
Dim iAdd As String
Dim ws As Worksheet
iRow = Me.TextBox20.Value
iAdd = .Cells(iRow, 1)
Call Get_Row
With UpdateForm
.TextBox2.Text = .iAdd.Offset(iRow, 0).Value
.TextBox3.Text = .iAdd.Offset(0, 1).Value
.TextBox4.Text = .iAdd.Offset(0, 2).Value
.ComboBox1.Text = .iAdd.Offset(0, 3).Value
.TextBox5.Text = .iAdd.Offset(0, 4).Value
.TextBox12.Text = .iAdd.Offset(0, 5).Value
.TextBox13.Text = .iAdd.Offset(0, 6).Value
.TextBox14.Text = .iAdd.Offset(0, 7).Value
.TextBox7.Text = .iAdd.Offset(0, 8).Value
.TextBox8.Text = .iAdd.Offset(0, 9).Value
.TextBox9.Text = .iAdd.Offset(0, 10).Value
.TextBox18.Text = .iAdd.Offset(0, 11).Value
End With
Application.ScreenUpdating = True
End Sub
模块代码:
Sub Get_Row()
Dim SelectRow As Range
Dim response As Integer
Dim UpdateForm As UserForm
Dim iRow As Object
Dim iAdd As String
Dim ws As Worksheet
Set iRow = UpdateForm.TextBox20.Value
Set iAdd = ws.Cells(iRow, 1)
End Sub