Macro Help (Barcode Scanner to Excel Sheet)

RebelDrummer

New Member
Joined
Jul 11, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Thanks for adding me - first post, lets hit the ground running

Here is what I am working with.
1.. Barcode / SKU scanner.
2 .. Excel Master Data List (all on one tab/sheet)

Here is what I am able to do now.
Take the scanner, scan a barcode on a product, excel finds that item and highlights the entire row

Here is what I would like to see happen, if possible.
Take the scanner, scan a barcode on a product, excel finds that information and creates a new row on the new tab/sheet with that data

Is this possible? Is creating a Macro the way?
I do appreciate the help in advance

Thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Yes, all you have to do now is use the Macro Recoder to copy your highlighted row to the other sheet. Then, once you have the code for the 'copy' part you need to make the macro dynamic so it can 'add' to the other sheet everytime you do a new reading with the scanner.
 
Upvote 0
Yes, all you have to do now is use the Macro Recoder to copy your highlighted row to the other sheet. Then, once you have the code for the 'copy' part you need to make the macro dynamic so it can 'add' to the other sheet everytime you do a new reading with the scanner.
first, thank you -
second, is there a video tutorial anywhere that will show me the basics of how to do this? i understand the macro recorder option via excel. however, I am not familiar with how to capture that code and make it dynamic to perform the second action (which would be adding it to the 2nd sheet/tab)
 
Upvote 0
Get yourself started with this LINK then came back with your macro if you don't manage to make it dynamic (better if in a new thread since it will be a different topic).
 
Upvote 0
Get yourself started with this LINK then came back with your macro if you don't manage to make it dynamic (better if in a new thread since it will be a different topic).
Thanks for the link. I am still struggling unfortunately. Here is the macro. The problem I am running into at the moment is that when I use the shortcut keys, no matter what I just scanned, it will only paste the info from the first data range that was found when recording macro. I know that its because the macro is specific to that cell information, so I guess I am stuck now trying to figure out how to make it to where it will copy / paste over the new scanned data each time.

Sub DataLogging1()
'
' DataLogging1 Macro
'
' Keyboard Shortcut: Ctrl+b
'
Cells.Find(What:="22060725", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
End Sub
 
Upvote 0
This could be your macro with shortcut key. I'm assuming that your barcode read ends up in cell A1 and the copied row is pasted in Sheet1:
VBA Code:
Option Explicit
Sub DataLogging1()
    '
    ' DataLogging1 Macro
    '
    ' Keyboard Shortcut: Ctrl+b
    '
    Dim lr     As Long
    Application.ScreenUpdating = False
    On Error GoTo notfound
    Range("A2:A" & Rows.Count).Find(What:=Range("A1"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate
    With Sheets("Sheet1")          '<- change as needed
        lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
        ActiveCell.EntireRow.Copy .Cells(lr, 1)
    End With
    GoTo nextscan
notfound:
    MsgBox "Item not found!"
nextscan:
    With Application
        .CutCopyMode = False
        .EnableEvents = False
        Range("A1").Select
        Range("A1").ClearContents
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub
but since your input is from a scanner I would use this other solution which triggers via event Worksheet_Change. This macro has to be pasted in the input sheet's module and I'm using cell A1 as support cell where the input of the scanner goes.
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim lr     As Long
    If Not Target.Address = "$A$1" Then Exit Sub  'if it isn't the cell chosen for input... <-- change cell as needed
    Application.ScreenUpdating = False
    On Error GoTo notfound
    Range("A2:A" & Rows.Count).Find(What:=Target.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate
    With Sheets("Sheet1")          '<- change as needed
        lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
        ActiveCell.EntireRow.Copy .Cells(lr, 1)
    End With
    MsgBox "Done!"
    GoTo nextscan
notfound:
    MsgBox "Item not found!"
nextscan:
    With Application
        .CutCopyMode = False
        .EnableEvents = False
        Range("A1").Select
        Range("A1").ClearContents
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub
 
Last edited:
Upvote 0
This could be your macro with shortcut key. I'm assuming that your barcode read ends up in cell A1 and the copied row is pasted in Sheet1:
VBA Code:
Option Explicit
Sub DataLogging1()
    '
    ' DataLogging1 Macro
    '
    ' Keyboard Shortcut: Ctrl+b
    '
    Dim lr     As Long
    Application.ScreenUpdating = False
    On Error GoTo notfound
    Range("A2:A" & Rows.Count).Find(What:=Range("A1"), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate
    With Sheets("Sheet1")          '<- change as needed
        lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
        ActiveCell.EntireRow.Copy .Cells(lr, 1)
    End With
    GoTo nextscan
notfound:
    MsgBox "Item not found!"
nextscan:
    With Application
        .CutCopyMode = False
        .EnableEvents = False
        Range("A1").Select
        Range("A1").ClearContents
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub
but since your input is from a scanner I would use this other solution which triggers via event Worksheet_Change. This macro has to be pasted in the input sheet's module and I'm using cell A1 as support cell where the input of the scanner goes.
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim lr     As Long
    If Not Target.Address = "$A$1" Then Exit Sub  'if it isn't the cell chosen for input... <-- change cell as needed
    Application.ScreenUpdating = False
    On Error GoTo notfound
    Range("A2:A" & Rows.Count).Find(What:=Target.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate
    With Sheets("Sheet1")          '<- change as needed
        lr = .Range("A" & Rows.Count).End(xlUp).Row + 1
        ActiveCell.EntireRow.Copy .Cells(lr, 1)
    End With
    MsgBox "Done!"
    GoTo nextscan
notfound:
    MsgBox "Item not found!"
nextscan:
    With Application
        .CutCopyMode = False
        .EnableEvents = False
        Range("A1").Select
        Range("A1").ClearContents
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub

The macro for use with scanner is ideal - however, USER ERROR I believe is the issue I am now facing (eyeroll, i know)
Its been a long time since I have had to use let alone create a macro
At this point, I am not sure what the best course of action is to see where I am going wrong
With this 2nd option set up - it is still not populating the scanned information on the 2nd worksheet.
All it does when the bar code is scanned is it finds the cell in which that data is stored.
 
Upvote 0
It's always hard to make suggestions not being able to see the exact layout of your data. A dummy file attached would be appreciated.
Anyway, as per the second option, I think that you haven't pasted the macro in the sheet's module. As said it uses an event macro so it won't work if pasted elsewhere. As a shortcut instead of going to the Editor, you can right-click the input sheet's Tag and then choose View Code.
 
Upvote 0
LoggingMockUp71422.xlsm
ABCDEFG
1SKUTypeManufacturerModel NumberModel DescriptionDepthPart #
222050001NERF1AB1234HEMI91A2B3C
322050002NERF2CD5678BOLT 3004D5E6F
422050003NERF3EF9876PUMP2707G8HI9
522050004NERF1AB1234HEMI91A2B3C
622050005NERF2CD5678BOLT 3004D5E6F
722050006NERF3EF9876PUMP2707G8HI9
822050007NERF1AB1234HEMI91A2B3C
922050008NERF2CD5678BOLT 3004D5E6F
1022050009NERF3EF9876PUMP2707G8HI9
1122050010NERF1AB1234HEMI91A2B3C
1222050011NERF2CD5678BOLT 3004D5E6F
1322050012NERF3AB9876PUMP2707G8HI9
1422050013NERF1CD1234HEMI91A2B3C
1522050014NERF2AB5678BOLT 3004D5E6F
1622050015NERF3CD9876PUMP2707G8HI9
1722050016NERF1AB1234HEMI91A2B3C
1822050017NERF2CD5678BOLT 3004D5E6F
1922050018NERF3EF9876PUMP2707G8HI9
car parts master
 
Upvote 0
LoggingMockUp71422.xlsm
ABCDEFG
1SKUTypeManufacturerModel NumberModel DescriptionDepthPart #
222050001NERF1AB1234HEMI91A2B3C
322050003NERF3EF9876PUMP2707G8HI9
422050008NERF2CD5678BOLT 3004D5E6F
522050010NERF1AB1234HEMI91A2B3C
622050013NERF1CD1234HEMI91A2B3C
722050014NERF2AB5678BOLT 3004D5E6F
822050015NERF3CD9876PUMP2707G8HI9
922050018NERF3EF9876PUMP2707G8HI9
customer 1 order
 
Upvote 0

Forum statistics

Threads
1,215,390
Messages
6,124,669
Members
449,178
Latest member
Emilou

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