Barcode Script

meppwc

Well-known Member
Joined
May 16, 2003
Messages
626
Office Version
  1. 365
Platform
  1. Windows
I am guessing that this topic has been addressed in the past. If anyone knows of where I can find the information that I seek I would greatly appreciate it.

I keep my inventory in Excel
Column A is a list of numbers that are unique that are also associated to the barcode on our boxes
I have a USB barcode reader

I am hoping that someone may have already created a script that when a barcode is read, it adds "1" to the existing amount on hand.
For example:
The barcode is read
The barcode is found in cell A5
The amount in B5 which is 6
"1" is automatically added to 6 and the new value in B5 is 7
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I guess my first question is this... is the barcode scanned into a cell? or a userform? Can you provide a sample file?
 
Upvote 0
Hi meppwc,

Hum! Simply by reading a bar code from a cell triggers an event to add one to a value in another cell. What would that event be in VBA or otherwise? I do not think this is possible, as you describe it, but again never say never, I have been shown some creative ways that did the job at hand.

I would suggest that you investigate some event that might trigger once your USB card reader is activated. You know writing this I got to think...

Possibly if you make the bar code return to the worksheet, say being stored in a particular cell, and that triggers the change event and then you can lookup the value of the bar code cell and find which one it is (what row it sits on) and then update the B5 in your example above.

The key is how do you get the bar code reader to send it back to Excel.

Good luck, and tell us what you end up with.

WassimN
 
Last edited:
Upvote 0
Typically barcode readers have a tab suffix after the scan, or can be configured to add that. As such, you could either use a worksheet change event (in the desired cell), or an exit (or afterupdate) event on a userform textbox. It could even be coded to return to the cell/textbox once the search and update has been completed. A more comprehensive answer would require much more detail however.
 
Upvote 0
An answer I posted to a similar question a couple years ago on a now defunct forum.
All bar code scans go into B2. Perhaps you can adapt to your needs.
The code goes in the sheet module.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim fndScan As Range
   
If Target.Address <> "$B$2" Then Exit Sub

With Range("A:A")
    Set fndScan = .Find(What:=Target.Value, _
                       LookIn:=xlValues, _
                       LookAt:=xlWhole, _
                       SearchOrder:=xlByRows, _
                       SearchDirection:=xlNext, _
                       MatchCase:=False)
   
    'to prevent this procedure from calling itself
    Application.EnableEvents = False
   
    If Not fndScan Is Nothing Then
        'just to show where found comment out later
        MsgBox Target.Value & " was found at  " & fndScan.Address
       
        With fndScan
            .Offset(0, 1).Value = .Offset(0, 1).Value + 1
        End With
    Else
        MsgBox Target.Value & " Not found"
    End If
End With

'clear and select B2 ready for next scan
Range("B2").ClearContents
Range("B2").Select

're-enable events
Application.EnableEvents = True

End Sub
 
Upvote 0
Thanks NoSparks...............I believe that may help.............once I get home (where my scanner is) I am hoping to do a CTRL+F and then scan a barcode.....the reader is connected via USB..........if the correct barcode populates the find field then there should be an automated way to then have excel find the record (if exists) and carry out the logic that I need.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top