我目前有一个userform,它应该将输入文本框和列表框的数据自动填充到我的Sheet1上的下一个可用行中。目前,按下“提交”按钮后,只会填充列表框。请帮我调试我的文本框,名称为txt ___
答案 0 :(得分:1)
如果你只尝试这个,它会起作用吗?
Option Explicit
Private Sub Submit_Click()
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.txtCompany.Value
.Cells(lRow, 2).Value = Me.txtPOC.Value
.Cells(lRow, 3).Value = Me.txtPhone.Value
.Cells(lRow, 4).Value = Me.txtEmail.Value
.Cells(lRow, 5).Value = Me.Contract.Value
.Cells(lRow, 6).Value = Me.Capability.Value
.Cells(lRow, 7).Value = Me.Agency.Value
.Cells(lRow, 8).Value = Me.txtDepartment.Value
.Cells(lRow, 9).Value = Me.Socioeconomic.Value
.Cells(lRow, 10).Value = Me.txtNotes.Value
End With
End Sub
更改是我引用Me
,认为您的代码位于Form
。