+ Reply to Thread
Results 1 to 11 of 11

[SOLVED] Finding a match after Barcode scanned

  1. #1
    Registered User
    Join Date
    09-15-2012
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    [SOLVED] Finding a match after Barcode scanned

    Hello All,
    A while ago I had some help from this forum to develop an inventory database, which is working well. Unfortunately I need your help again. I have searched and found a few related posts that I though that I could use to help me, but I am getting nowhere.

    So hopefully you wont mind in helping again.

    I now need to add a VBA to monitor Cell E3 on Sheet 'ALL STOCK NEW. When I scan a barcode into this active cell E3, I would like a VBA to search for a match and select that cell. After this I can add my existing VBA to select the row and copy to another sheet.

    I have attached the Workbook.

    Hopefully you don't mind help and hope you understand my request or may be point me in the right direction.

    Thanks in advance.

    Creeky
    Attached Files Attached Files
    Last edited by creekybones; 09-17-2019 at 05:29 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    You should be able to use the Worksheet Change event to monitor cell E3.

    Where are you searching for matching barcodes? I don't see that column heading in the sheet.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  3. #3
    Registered User
    Join Date
    09-15-2012
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Finding a match after Barcode scanned

    Hello MatrixMan
    Thank you very much for your reply, I’ll have a look at the change event.
    I will be looking for a match in the columns labelled ‘Part Number’ and ‘RS No’. Then select the matching cell.

  4. #4
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    Great - it should be straight-forward, provided the change event recognises the cell change when you scan a barcode; assuming it does, then in the change event you can use .Find to look for an exact match (LookAt:=xlWhole) in the part number column.

    Let me know if you get stuck - good luck.

  5. #5
    Registered User
    Join Date
    09-15-2012
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Finding a match after Barcode scanned

    Perfect. I’ll have a go and get back to you.
    Thanks for your help.

  6. #6
    Registered User
    Join Date
    09-15-2012
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Finding a match after Barcode scanned

    Hello Matrix man,
    I have managed to get the code working when the cell value changes, but it only works with numbers (i.e 12). If I enter a number with hyphen in it (ie 877-1160) the vba code does not work at all, nothing happens. I don't even get the Not Found message box. This also happens if I enter 'M4x10' into the cell.

    Would be great-full if you could help.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim iVal As Long
    Dim cell As Range

    If Target.Address = "$E$3" Then
    If VarType(Target.Value) = vbDouble Then
    iVal = Target.Value
    Set cell = Range("B4", Cells(Rows.Count, "B").End(xlUp)).Find(What:=iVal, LookIn:=xlFormulas, lookat:=xlWhole)
    If cell Is Nothing Then
    MsgBox "Not found: " & iVal
    Else
    cell.Select
    End If
    End If
    End If
    End Sub

  7. #7
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    Can you post your workbook with the current code?

  8. #8
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    Actually ...

    You have defined iVal as long but then assigned Target.Value to it if it is double ... if you have a hyphen or other text characters it won't be a double and will skip your code.

  9. #9
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    So something like this:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-15-2012
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Finding a match after Barcode scanned

    Hello Matrix Man,
    Your code works, Thank you very much for your help.

    Very much appreciated.

    I can now finish the rest of the coding.

    Thank you for spending the time to help.

  11. #11
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Finding a match after Barcode scanned

    You're welcome ... don't forget to mark the thread solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 08-24-2022, 12:27 AM
  2. Replies: 1
    Last Post: 07-10-2015, 03:15 PM
  3. Barcodes sometimes cant be bleeped/scanned using barcode gun
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2015, 09:09 AM
  4. Update spreadsheet when a barcode is scanned
    By fuzzyexcel in forum Excel General
    Replies: 0
    Last Post: 11-06-2014, 04:51 PM
  5. Need to copy 9 cells to another worksheet when barcode is scanned
    By MOMO7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-03-2014, 05:00 AM
  6. Adding Date in Column When Barcode is Scanned
    By zwarner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2013, 10:59 PM
  7. Switch worksheet depending on barcode scanned?
    By Mattneedshelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1