Need help with barcode scanner excel sheet (VBA)

drowe005

New Member
Joined
Jan 27, 2015
Messages
39
WHAT I CURRENTLY HAVE:

Here is a screenshot of my current excel spreadsheet:

15766767804_b18d0d787a_s.jpg
[/URL][/IMG]

Here is a copy of the code I am currently using:

Code:
Option ExplicitPrivate Sub Worksheet_Change(ByVal Target As Range)
' hiker95, 12/18/2012
' http://www.mrexcel.com/forum/excel-questions/672492-scan-barcode-excel-date-time-stamp-out.html
If Intersect(Target, Range("A2:A3000")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
Dim lc As Long, fr As Long, n As Long, nr As Long
With Application
  .EnableEvents = False
  .ScreenUpdating = False
  n = Application.CountIf(Columns(1), Cells(Target.Row, 1))
  If n = 1 Then
    lc = Cells(Target.Row, Columns.Count).End(xlToLeft).Column
    If lc = 1 Then
      Cells(Target.Row, lc + 2) = Format(Now, "m/d/yyyy h:mm")
    ElseIf lc > 2 Then
      Cells(Target.Row, lc + 1) = Format(Now, "m/d/yyyy h:mm")
    End If
  Else
    fr = 0
    On Error Resume Next
    fr = Application.Match(Cells(Target.Row, 1), Columns(1), 0)
    On Error GoTo 0
    If fr > 0 Then
      lc = Cells(fr, Columns.Count).End(xlToLeft).Column
      If lc = 1 Then
        Cells(fr, lc + 2) = Format(Now, "m/d/yyyy h:mm")
      ElseIf lc > 2 Then
        Cells(fr, lc + 1) = Format(Now, "m/d/yyyy h:mm")
      End If
      Target.ClearContents
    End If
  End If
  On Error Resume Next
  Me.Range("A1", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  On Error GoTo 0
  nr = Me.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
  Me.Cells(nr, 1).Select
  .EnableEvents = True
  .ScreenUpdating = True
End With
End Sub

Currently the way the excel sheet works: if you enter a value into column A and it is an original piece of data, it will add a date/time stamp onto the row in column C. If you repeat that same piece of data again further down the column, it will recognize that it is a duplicate and add a "time out" in column D on the row that this same piece of data was already entered. It will also delete that whole row of the duplicate too.


WHAT I WOULD LIKE MY EXCEL SHEET TO DO:


This is how I would like my excel sheet set up:

16202999219_a24f19b45d_s.jpg
[/URL][/IMG]

Columns A and B would be data input either via keyboard or barcode scanner. Column C would be "Column A/Column B" as to make a unique number combination. Column A is employee ID number and Column B is Manufacturing Order number. The whole goal of having that Column C is so that you have a unique number tying that employee to a certain job. The main reason is that you can have several employees working on the same MO, but only one MO can be worked by any given employee at a time.

I have found what I thought to be a solution by entering an excel forumla to calculate that "Column A/Column B" but apparently excel forumlas negate the VBA code of the same cell. So I need VBA to automatically calculate column C after BOTH column A and column B have been entered, and this leading to the time stamp being placed.


Hopefully I explained this well enough, and any help would be greatly appreciated! Thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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