inputID >>自动search空白单元格>>防止excelclosures>>重新inputIDclosures

这个想法是提示一个input框,要求用户inputID,只有数字值。 那么它将自动search在列H中创build的第一个空白单元,以允许从那里input条形码。 而用户使用蓝牙条形码扫描仪远离电脑的条形码键时,Excel不能被其他用户closures。 要closures它,用户必须input相同的ID代码只能工作,直到input值为真,那么它不会select单元格

Sub Enter_1() Dim data_1 As String Dim sCell As Variant Dim rslt As Boolean Do data_1 = InputBox(Prompt:="Enter Employee No.", Title:="Employee", Default:="Enter Employee No. here") If data_1 = "" Then QuestionToMessageBox = "Exit?" YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox, vbYesNo, "Cancel") End If If YesOrNoAnswerToMessageBox = vbNo Then data_1 = InputBox(Prompt:="Enter Employee No.", Title:="Employee", Default:="Enter Employee No. here") Else Exit Sub End If rslt = False If Not IsNumeric(data_1) Then MsgBox "You can only enter a number in this field" rslt = True Run (rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row) End If Loop While rslt End Sub Public Sub MessageBoxYesOrNoMsgBox() Dim YesOrNoAnswerToMessageBox As String Dim QuestionToMessageBox As String End Sub Public Sub SelectFirstBlankCell() Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer Dim currentRowValue As String sourceCol = 8 'column H has a value of 8 rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row 'for every row, find the first blank cell and select it For currentRow = 1 To rowCount currentRowValue = Cells(currentRow, sourceCol).Value If IsEmpty(currentRowValue) Or currentRowValue = "" Then Cells(currentRow, sourceCol).Select End If Next End Sub Sub Enter_2(ByVal data_1 As Long, ByRef data_1 As Long) Dim data_2 As String Dim rslt As Boolean Do data_2 = InputBox(Prompt:="Enter Employee No.", _ Title:="Employee", Default:="Enter Enter Employee No. here") If data_2 = "" Then MsgBox ("Cancel") Exit Sub rslt = False If Not IsNumeric(data_2) Then MsgBox "You can only enter a number in this field" If rslt = True Then End If Loop While rslt If data_2 <> data_1 Then MsgBox "Enter correct E.No" End If End Sub Private Sub Force(ByVal data_1 As Long, ByRef data_2 As Long) Dim cancel As Boolean Dim allow_close As Boolean If data_1 = data_2 Then allow_close = True Else allow_close = False End If End Sub