我希望填充一个可以让我执行以下功能的vb代码:
以下是我的用户形式:
点击添加股票按钮后,它会上传我填写的名为库存的数据表(A4:A6)
产品和现场库存填充后,将自动生成红色。
对于可用库存,可以搜索库存中的整个数据表,以总结所有正在添加的库存或最后可用库存量。
如果内部库存表不包含产品(新产品),它将自动显示0或空白到用户表单中的库存可用字段。
点击添加股票按钮后,它会上传我填写的名为库存的数据表(A7)
我不知道如何将数据导入我的库存表。
谢谢或先进的帮助
我的代码将是这样的:
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
答案 0 :(得分:0)
试试这个:
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