+ Reply to Thread
Results 1 to 14 of 14

Inventory management help needed. Scanning like numbers into spreadsheets

Hybrid View

  1. #1
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Inventory management help needed. Scanning like numbers into spreadsheets

    Hello all I am new to the Forums and have found them extremely helpful. Thank you all so much for asking and answering questions I have been trying to solve.
    The problem I am having is this. I am setting up a scanner to manage a parts inventory. I use the vendors bar codes which makes my job a bit easier and less expensive. This is working great other than we have parts that date back a few years at which time the vendor added a " -0000 " to the bar code part numbers. The barcode numbers are " XXXXX-XXXXX " and " XXXXX-XXXXX-XXX ". I would just have the scanner ignore the digits however as you can see some of the part numbers have " -XXX ". The part numbers are letters and numbers combined IE 99500-15234-F01 or K1245-67890. With the older bar codes the previous part numbers read " 99500-15234-F010 or K1245-67890-0000 " The module I have pulls the part number and description from page 2 into the working page and adds +1 to the quantity. Every time the same number is scanned it adds +1 to the quantity. I am wondering if there is a macro/ module I can run to solve the extra digits added so my inventory sheet does not need an extra step when completed. I am using a module found on this site by one of the members. I have attached a copy of the code so you have an idea of what I am working with.
    To simplify. I scan XXXXX-XXXXX and get XXXXX-XXXXX-0000 or XXXXX-XXXXX-XXX and get XXXXX-XXXXX-XXX0 only on older bar codes. I have the same part purchased years apart with the same part number only the old one adds the -0000. I hope I was clear enough. ANy help would save me. Thank you.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim Item As String
    Dim strDscrpt As String
    Dim strPrice As String
    Dim SearchRange As Range
    Dim rFound As Range
    
    'Don't run the macro if:
    'Target is not a single cell:
    If Target.Cells.Count > 1 Then Exit Sub
    'or Target belongs to the A1.CurrentRegion:
    If Not Intersect(Target, Range("A1").CurrentRegion) Is Nothing Then Exit Sub
    
    'Avoid the endless loop:
    Application.EnableEvents = False
    
    'Looks for matches from here first:
    Set SearchRange = Range("A1:A" & Range("A1").CurrentRegion.Rows.Count)
        
    Item = Target.Value
    
    'Clears the Target:
    Target.Value = ""
    
    If Application.WorksheetFunction.CountIf(SearchRange, Item) > 0 Then
    'There's a match already:
        Set rFound = Columns(1).Find(What:=Item, After:=Cells(1, 1) _
                , LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows _
                , SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    'Adds one to the Quantity:
            rFound.Offset(0, 2).Value = rFound.Offset(0, 2).Value + 1
            rFound.Activate
            Application.Goto ActiveCell, True
    Else
    
    'Writes the value for the Barcode-list:
    Range("A" & SearchRange.Rows.Count + 1).Value = Item
    
    'Looks for the match from sheet "Inventory" column A
        With Sheets("Inventory")
            Set rFound = .Columns(1).Find(What:=Item, After:=.Cells(1, 1) _
                    , LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows _
                    , SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        
            On Error GoTo 0
        
                If Not rFound Is Nothing Then
    'Writes the Product Name and adds 1 to the Quantity column:
                    Range("B" & SearchRange.Rows.Count + 1).Value = rFound.Offset(0, 1).Value
                    Range("C" & SearchRange.Rows.Count + 1).Value = 1
                    
                    'Scroll worksheet to the current item in case user want to see it or work with it.
                    Range("C" & SearchRange.Rows.Count + 1).Activate
                    Application.Goto ActiveCell, True
                    
                Else
                    'The Product isn't in the Inventory sheet.
                    'sound beep to alert user to add description and price.
                    Range("C" & SearchRange.Rows.Count + 1).Value = 1
                    
                    Beep
                    For i = 1 To 15000000
                        'just killing one second or so, so we can get a second 'beep' in.
                        Next i
                    Beep
                    
                    ' IF user is quick to scan another barcode then the description would be entered as that barcode.
                    ' So we avoid this by checking if the discription entered is a number or if its blank and loop
                    ' until we get the user to enter some text. If a description is actually a number then user should procede the number
                    ' with a single quote mark. This ensures that the user really want to enter a number as a description.
                    
                    Do
                        strDscrpt = InputBox("Enter Description for Barcode: " & Range("A" & SearchRange.Rows.Count + 1).Value & vbCr & vbLf & "(24 characters max)", "Item Not found in Inventory List")
                    Loop While IsNumeric(strDscrpt) Or (Len(Trim(strDscrpt)) = 0)
                    
                    Range("B" & SearchRange.Rows.Count + 1).Value = strDscrpt
                    
                    Beep
                    Do
                        strPrice = InputBox("Now enter the regular PRICE for: " & UCase(strDscrpt) & vbCr & vbLf & "(With decimal point. example: 12.99)", "Price for Barcode: " & Range("A" & SearchRange.Rows.Count + 1).Value)
                    Loop While Not IsNumeric(strPrice)
                    
                    Range("D" & SearchRange.Rows.Count + 1).Value = Val(strPrice)
                    
                    'Scroll worksheet to the current item in case user want to see it or work with it.
                    Range("C" & SearchRange.Rows.Count + 1).Activate
                    Application.Goto ActiveCell, True
                End If
        End With
    End If
    
    Range("F1").Value = "Scan Barcode Here"
    Range("F1").Select
    
    'Enable the Events again:
    Application.EnableEvents = True
    
    
    End Sub

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Hi Watersboy,

    Is it that you want to strip the trailing zero(s) from the 16 - length codes???
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    If I scan part number 99023-12654 or 99023-12654-0000 which are the same item I want it to only add to one field 99023-12654. Right now it adds a new line. I can not just leave off the last 5 (-0000) as some parts numbers do have an additional -XXX ie 99023-12654-019.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Yeah but are the ones that bug you all 16 figures???

  5. #5
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Yes that is correct. My parts files are mainly 11 digit and some 15 digit.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Hi Watersboy,

    This will fix your inventory sheet if the part numbers are in the A column:

    Sub Watersboy(): Dim A As Range, ws As Worksheet, r As Long
    Set ws = ActiveWorkbook.Worksheets("Inventory")
    r = ws.Range("A" & Rows.Count).End(xlUp).Row
    For Each A In ws.Range("A1:A" & r)
    If Len(A) = 16 Then
    If Right(A, 5) = "-0000" Then
    A = Left(A, 11)
    ElseIf Right(A, 1) = "0" Then
    A = Left(A, 15): End If
    End If: Next: End Sub

  7. #7
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Thank you so much for taking your time for this. I am going to implement it today. I will let you know how it goes.

  8. #8
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Well I am having an issue implementing. I am inserting this into the active ws with no effect. You will have to forgive me I am leaning as I go. I have spent about 2 hours this morning trying to make it work on my own so I would not have to bother any help would be great. I will attach my workbook.

  9. #9
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Here is a copy of my workbook. Thank you for any help.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    From what I understand the code provided will edit the Inventory Sheet. My inventory sheet is in the correct format IE 11 digit or 15 digit. The problem I have is with the number being scanned into INV Taken Sheet. It wants me to set up a new item even though the item is already set up in the correct format.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Hi Watersboy,

    This does the trick:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim Item As String
    Dim strDscrpt As String
    Dim strPrice As String
    Dim SearchRange As Range
    Dim rFound As Range
    
    'Don't run the macro if:
    'Target is not a single cell:
    If Target.Cells.Count > 1 Then Exit Sub
    'or Target belongs to the A1.CurrentRegion:
    If Not Intersect(Target, Range("A1").CurrentRegion) Is Nothing Then Exit Sub
    
    'Avoid the endless loop:
    Application.EnableEvents = False
    
    'Looks for matches from here first:
    Set SearchRange = Range("A1:A" & Range("A1").CurrentRegion.Rows.Count)
    
    
    If Len(Target) = 16 Then
    
    If Right(Target, 5) = "-0000" Then
    Target = Left(Target, 11)
    ElseIf Right(Target, 1) = "0" Then
    Target = Left(Target, 15): End If
    
    End If
    
    Item = Target.Value
    
    
    
    'Clears the Target:
    Target.Value = ""
    
    If Application.WorksheetFunction.CountIf(SearchRange, Item) > 0 Then
    'There's a match already:
        Set rFound = Columns(1).Find(What:=Item, After:=Cells(1, 1) _
                , LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows _
                , SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    'Adds one to the Quantity:
            rFound.Offset(0, 2).Value = rFound.Offset(0, 2).Value + 1
            rFound.Activate
            Application.Goto ActiveCell, True
    Else
    
    'Writes the value for the Barcode-list:
    Range("A" & SearchRange.Rows.Count + 1).Value = Item
    
    'Looks for the match from sheet "Inventory" column A
        With Sheets("Inventory")
            Set rFound = .Columns(1).Find(What:=Item, After:=.Cells(1, 1) _
                    , LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows _
                    , SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        
            On Error GoTo 0
        
                If Not rFound Is Nothing Then
    'Writes the Product Name and adds 1 to the Quantity column:
                    Range("B" & SearchRange.Rows.Count + 1).Value = rFound.Offset(0, 1).Value
                    Range("C" & SearchRange.Rows.Count + 1).Value = 1
                    
                    'Scroll worksheet to the current item in case user want to see it or work with it.
                    Range("C" & SearchRange.Rows.Count + 1).Activate
                    Application.Goto ActiveCell, True
                    
                Else
                    'The Product isn't in the Inventory sheet.
                    'sound beep to alert user to add description and price.
                    Range("C" & SearchRange.Rows.Count + 1).Value = 1
                    
                    Beep
                    For i = 1 To 15000000
                        'just killing one second or so, so we can get a second 'beep' in.
                        Next i
                    Beep
                    
                    ' IF user is quick to scan another barcode then the description would be entered as that barcode.
                    ' So we avoid this by checking if the discription entered is a number or if its blank and loop
                    ' until we get the user to enter some text. If a description is actually a number then user should procede the number
                    ' with a single quote mark. This ensures that the user really want to enter a number as a description.
                    
                    Do
                        strDscrpt = InputBox("Enter Description for Barcode: " & Range("A" & SearchRange.Rows.Count + 1).Value & vbCr & vbLf & "(24 characters max)", "Item Not found in Inventory List")
                    Loop While IsNumeric(strDscrpt) Or (Len(Trim(strDscrpt)) = 0)
                    
                    Range("B" & SearchRange.Rows.Count + 1).Value = strDscrpt
                    
                    Beep
                    Do
                        strPrice = InputBox("Now enter the regular PRICE for: " & UCase(strDscrpt) & vbCr & vbLf & "(With decimal point. example: 12.99)", "Price for Barcode: " & Range("A" & SearchRange.Rows.Count + 1).Value)
                    Loop While Not IsNumeric(strPrice)
                    
                    Range("D" & SearchRange.Rows.Count + 1).Value = Val(strPrice)
                    
                    'Scroll worksheet to the current item in case user want to see it or work with it.
                    Range("C" & SearchRange.Rows.Count + 1).Activate
                    Application.Goto ActiveCell, True
                End If
        End With
    End If
    
    Range("F1").Value = "Scan Barcode Here"
    Range("F1").Select
    
    'Enable the Events again:
    Application.EnableEvents = True
    
    
    End Sub

  12. #12
    Forum Contributor
    Join Date
    01-13-2013
    Location
    Oklahoma
    MS-Off Ver
    Office 2007 / Office 2010
    Posts
    123

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Place this under the red line in your module:
    Item = Target.Value
    If Len(Item) = 16 Then
        Do Until Right(Item, 1) <> "0"
            Item = Left(Item, Len(Item) - 1)
        Loop
        If Right(Item, 1) = "-" Then Item = Left(Item, Len(Item) - 1)
    End If

  13. #13
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    Gosh Thank you so much. That does exactly what I need it to. You guys are great. Your time is very much appreciated.

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inventory management help needed. Scanning like numbers into spreadsheets

    You're welcome!

    BTW one forum guru say's "one spreadsheet is worth a thousand pictures"

    (You can use both! mine before item and Yraen's after item!)
    Last edited by xladept; 04-06-2013 at 02:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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