Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

the Tool.

0

c. 
gh

gu

Answer
Discuss

Discussion

Hello.
How do you get the data from the scanner onto your computer?
k1w1sm (rep: 197) Sep 15, '19 at 12:56 am
Hi 
My knowledge of scanners is a bit limmited. I undrstood that they had built in software to store and the down load the data using usb connection or even wirelessly over wifi. I think we need the to know the type of scanner and access to its operating or a description of how it interacts with your machine as if excel did not exist.
A most interesting puzzel I hope to help and learn with you. 
k1w1sm (rep: 197) Sep 15, '19 at 3:00 pm
What have you got so far?
If you have your excel form open and a cell selected then atttach the scanner  is the cell populated when you scan a barcode? 
k1w1sm (rep: 197) Sep 15, '19 at 5:53 pm
I have madde a bit of a start.
From what I understand you do not want to enter the same barcode more than once I woud sugget a find on the barcode entered against those previously enter.
Private Sub txtID_Barcode_Change()
'the following line is just for debug to check that the barcode has been entered
MsgBox "New Data = " & TextBox1
 
Dim NewBarcode
Dim LastRow As Integer
Dim SearchRange As Range
 
 
NewBarcode = TextBox1.Value
 
'check to see if this barcode has been used
' do a ind on the previously loaded barcodes
'get last row in serch column
'LastRow = Range("E1").End(xlDown).Row
LastRow = Worksheets("Sheet1").Range("A1").SpecialCells(xlCellTypeLastCell).Row
 
Set SearchRange = Worksheets("Sheet1").Range(Cells(1, "B"), Cells(LastRow, "B"))
 
' find needs to go here - run out of time will have a look tommorrow and carry on
 'if you have not solved it youself
 
End Sub
k1w1sm (rep: 197) Sep 15, '19 at 11:14 pm
Contt, this is awful! please edit your question to include both the code you already have and the question you have regarding that code. Nobody wants to look for your question in the discussion.
Then add one detail to your question which is conspiciously missing: How do you connect your four scanners to your computer? Are they in fact all connected to the same PC? Are they connected to an RS232 port or to a USB port? Or are you, in fact, using the same scanner to to scan 4 different barcodes?
Variatus (rep: 4889) Oct 3, '19 at 1:39 pm
what ??????????
k1w1sm (rep: 197) Nov 5, '19 at 4:54 pm
Add to Discussion

Answers

0

Here is some code that will check the Barcode being added against those already added. Currently it just raise a message box.

You will need to tweek this code to perform your current business function when this situation occurs

This requires that the Barcode be entered completely in one hit (Paste or scan) as the code runs on the entry of a single character if you type it in

Private Sub txtID_Barcode_Change()
'the following line is just for debug to check that the barcode has been entered
MsgBox "New Data = " & txtID_Barcode


Dim NewBarcode
Dim LastRow As Integer
Dim SearchRange As Range
Dim c

NewBarcode = txtID_Barcode.Value

'check to see if this barcode has been used
' do a ind on the previously loaded barcodes
'get last row in serch column
'LastRow = Range("E1").End(xlDown).Row
LastRow = Worksheets("Sheet1").Range("A1").SpecialCells(xlCellTypeLastCell).Row

Set SearchRange = Worksheets("Sheet1").Range(Cells(1, "B"), Cells(LastRow, "B"))

    With SearchRange
        Set c = .Find(What:=NewBarcode, LookIn:=xlValues, _
                LookAt:=VBA.Trim(xlWhole), SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)
    End With

    If Not c Is Nothing Then  'has been found
      MsgBox NewBarcode & " Found"
    End If


End Sub
Discuss

Discussion

Try that.
I had just made up a userform which did not have all the fields names matching those in your userform.
The as I posted it I changed the name without changing all the other references.
As I do not have your excel or userform then this is my best best guess. Feel free to fix any other errors.
k1w1sm (rep: 197) Sep 16, '19 at 8:24 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login