Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Button1()
- ' TODO: Set the active cell where it says "here" loads
- ' Then find the row of the active cell
- ' https://excel-macro.tutorialhorizon.com/vba-excel-select-and-activate-cells-activate/
- ' https://stackoverflow.com/questions/43654157/how-to-find-cell-containing-string-in-entire-worksheet
- ' https://www.mrexcel.com/forum/excel-questions/68015-return-row-number-active-cell.html
- On Error GoTo Whoops
- Dim errorCode As Integer ' So that we can handle the error
- Dim barcodeNum As String
- Dim tempItemStr As String
- Dim displayString As String ' Just to tell the customer what is happening
- displayString = ""
- Do
- ' Take input & check number
- barcodeNum = InputBox("Scan barcode now. " + vbCrLf + "Click okay or press enter when the number" + vbCrLf + "appears in the box", "New Scan")
- If (!IsNumeric(barcodeNum)) Then
- errorCode = 1
- GoTo Whoops
- End If
- ' Find the thing and return some values here please
- ' 1. Finds the cell containing that string
- Dim rngFound As Range
- ' When we rename the sheet, change sheet1 to something else
- With Worksheets("Sheet1").Cells
- Set rngFound = .Find(barcodeNum, LookIn:=xlValues)
- If Not rngFound Is Nothing Then
- ' HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE HERE
- Else
- errorCode = 404
- GoTo Whoops
- End If
- End With
- ' Then add it to the string please
- displayString = displayString + tempItemStr
- ' Put this into an inputBox and take response please
- Loop While True
- Whoops:
- ' Handle error here
- If (errorCode = 0) Then
- MsgBox "Complete", , "Complete"
- End If
- MsgBox "Something went wrong ", , "Error: " + errorCode
- ' 1 = invalid input (string)
- ' 404 = not found
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement