我需要创建一个输入框,其中有多个输入框可以输入多个信息。他们是: -输入经销商名称 -输入经销商编号 -VPR等级 包装等级 -安装日期 -行动 -审核日期 -损耗比
一旦用户输入了所有信息并单击Submit按钮,该信息便被复制到另一张纸上并充当存储库。输入多个数据后,数据将从下一个可用空白行开始复制到存储库工作表中。
我需要宏,有人可以帮我怎么做
答案 0 :(得分:0)
您将必须重命名控件以符合代码中的内容。 以下代码在该用户表单中。
希望对您有帮助。
Private Sub cmdConfirmEntry_Click()
Dim iNumNonEmpty, iRowNumCurr, iColNumCurr As Integer
Worksheets("test entries").Activate
With ActiveSheet
Range("A1").Select
iColNumCurr = Range("A1").Column
iRowNumCurr = Range("A1").Row
iNumNonEmpty = Range("A1:A10000").Cells.SpecialCells(xlCellTypeConstants).Count
Cells(iRowNumCurr + iNumNonEmpty, iColNumCurr).Activate
Cells(ActiveCell.Row, iColNumCurr) = Me.txtDealerName.Value
Cells(ActiveCell.Row, iColNumCurr + 1) = Me.txtDealerNumber.Value
Cells(ActiveCell.Row, iColNumCurr + 2) = Me.txtVPRLevel.Value
Cells(ActiveCell.Row, iColNumCurr + 3) = Me.txtPacLevel.Value
Cells(ActiveCell.Row, iColNumCurr + 4) = Me.txtInstallDate.Value
Cells(ActiveCell.Row, iColNumCurr + 5) = Me.txtAction.Value
Cells(ActiveCell.Row, iColNumCurr + 6) = Me.txtReviewDate.Value
Cells(ActiveCell.Row, iColNumCurr + 7) = Me.txtLoasRation.Value
End Sub
答案 1 :(得分:0)
我会避免使用Activate
和Select
。这可能是您想要的,但是您需要调整“工作表名称”之类的内容。
Private Sub OK_Click()
Dim LastRow As Long
LastRow = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, 1).End(xlUp).Row + 1
Cells(LastRow, 1).Value = UserForm1.TextBox1.Value
Cells(LastRow, 2).Value = UserForm1.TextBox2.Value
Cells(LastRow, 3).Value = UserForm1.TextBox3.Value
Cells(LastRow, 4).Value = UserForm1.TextBox4.Value
Cells(LastRow, 5).Value = UserForm1.TextBox5.Value
Cells(LastRow, 6).Value = UserForm1.TextBox6.Value
Unload Me
End Sub