Trying to use a barcode scanner to automatically search a spreadsheet and check it off (routine verifications of assets).
I recorded the macro and it searches a specific string then changes the cell color to "check it off".
How can I make it wait for input from the scanner then search that input instead? I want the "IT2000" to be a variable that changes based on the barcode scanner.
Recored Macro:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+b
'
Sheets("S15-137").Select
Cells.Find(What:="IT2000", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Selection.Style = "Good"
End Sub
tried this and the scanner input works now but the code is failing. Also, how do I make it search all sheets by default?
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+b
'
Dim scannerInput As String
Dim cellFound As Range
scannerInput = Application.InputBox("Scan barcode")
Set cellFound = ThisWorkbook.Sheets("S15-137").Cells.Find(What:=Barcode, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not cellFound Is Nothing Then
cellFound.Style = "Good"
Else
MsgBox "Value not found"
End If
End Sub