我正在尝试创建一个用户表单,以与正在创建的电子表格一起使用。在电子表格上,我输入条形码,然后从单独的电子表格中提取相应的描述,并将其输入到描述列中。然后,用户只需要输入数量即可。我创建了一个用户表单,该表单应将信息输入电子表格中。我想做的是在用户表单中输入条形码后显示描述(在电子表格的第3列中)。
Private Sub Cmdbutton_add_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Barcode number
If Trim(Me.textbox_barcode.Value) = "" Then
Me.textbox_barcode.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_barcode.Value
ws.Cells(iRow, 2).Value = Me.textbox_quantity.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_barcode.Value = ""
Me.textbox_quantity.Value = ""
Me.textbox_barcode.SetFocus
End Sub
Private Sub Cmdbutton_close_Click()
Unload Me
End Sub
Private Sub description_Click()
End Sub
Private Sub quantity_Click()
End Sub
Private Sub textbox_barcode_Change()
End Sub
Private Sub textbox_quantity_Change()
End Sub
Private Sub TextBox1_Change()
End Sub