VB代码:导入用户表单数据到Excel工作表

我希望填充一个VB代码,可以让我做以下function:

以下是我的用户表单:

条件1: 在这里输入图像描述

点击“添加库存”button后,将上传填写名为“库存”(A4:A6)的数据表中的数据

一旦产品和库存被填满,红色将自动生成。

对于可用的库存,将能够search库存中的整个数据表以总结所有正在添加的库存或可用库存的最后一个库存量。

如果库存表中不包含产品(新产品),它将自动显示0或空白到userform中的库存可用字段。

条件2: 在这里输入图像描述

点击添加股票button后,它将上传填写名为库存(A7)的数据表中的数据

提交后,清单表应该看起来像这样:点击添加股票button: 在这里输入图像描述

我不知道如何将数据导入我的清单工作表。

感谢或在先进的帮助

我的代码将是这样的:

Private Sub Addstock_Click() Dim lRow As Long Dim ws As Worksheet Set ws = Worksheets("Inventory") lRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1 With ws .Cells(lRow, 1).Value = Me.ordernumber.Value '.Cells(lRow, 2).Value = Me.TextBox5.Value .Cells(lRow, 3).Value = Me.supplier.Value .Cells(lRow, 4).Value = Me.productname.Value .Cells(lRow, 5).Value = Me.stockavai.Value .Cells(lRow, 6).Value = Me.qty.Value .Cells(lRow, 7).Value = Me.newstock.Value .Cells(lRow, 8).Value = Me.unit.Value .Cells(lRow, 9).Value = Me.amount.Value End With End Sub 

尝试这个:

 Private Sub Addstock_Click() Dim lRow As Long Dim ws As Worksheet Set ws = Worksheets("Inventory") lRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues) With ws .Cells(lRow.Row + 1, 1).Value = Me.ordernumber.Value '.Cells(lRow.Row + 1, 2).Value = Me.TextBox5.Value .Cells(lRow.Row + 1, 3).Value = Me.supplier.Value .Cells(lRow.Row + 1, 4).Value = Me.productname.Value .Cells(lRow.Row + 1, 5).Value = Me.stockavai.Value .Cells(lRow.Row + 1, 6).Value = Me.qty.Value .Cells(lRow.Row + 1, 7).Value = Me.newstock.Value .Cells(lRow.Row + 1, 8).Value = Me.unit.Value .Cells(lRow.Row + 1, 9).Value = Me.amount.Value End With End Sub