Consulting

Results 1 to 4 of 4

Thread: Scanning Input not considered a Change

  1. #1
    VBAX Newbie
    Joined
    Jul 2019
    Posts
    5
    Location

    Post Scanning Input not considered a Change

    I am using a scanner to input data into an excel spreadsheet. Unfortunately, when I scan in the information, it is not considering it as a "Change" so the macro is not being triggered. The information from the scanner is being inserted into cells in columns A:L. Is there a setting or something I need to change to capture this input as a change?


    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim myTableRange As Range
    Dim myDateTimeRange As Range

    Set myTableRange = Range("A1:N20000")
    If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
    Set myDateTimeRange = Range("P" & Target.Row)
    If myDateTimeRange.Value = "" Then
    myDateTimeRange.Value = Now
    End If

    End Sub

  2. #2
    VBAX Regular
    Joined
    Feb 2013
    Posts
    52
    Location
    Unlike a textbox change event which fires with each key stroke, the worksheet_change event doesn't fire until you exit the cell.

  3. #3
    VBAX Newbie
    Joined
    Jul 2019
    Posts
    5
    Location
    So I am also using this on for the excel module. It always exits to the next empty cell in column A. The issue I'm running into is if multiple scans come in simultaneously, only the first one writes. With your comment above, I now understand why. Do you see a way to fix that issue?

    Sub Save1()
    Application.DisplayAlerts = False
    ThisWorkbook.Save


    'These next 2 columns put the date and time that the record went through in column O

    Range("O" & Rows.Count).End(xlUp).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A" & Rows.Count).End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("O1").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-14]="""","""",NOW())"
    ActiveCell.Offset(1, 0).Range("A1").Select

    'These next 2 columns put the time that the record went through in column R
    Range("R" & Rows.Count).End(xlUp).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("A" & Rows.Count).End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("R1").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-17]="""","""",NOW()-TODAY())"
    ActiveCell.Offset(1, 0).Range("A1").Select

    'These next 2 columns put the time that match the date up with the date that should be in the lot code
    Range("S" & Rows.Count).End(xlUp).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("A" & Rows.Count).End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("S1").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",IF(RC[-1]<TIME(07,15,00),TODAY()-1,TODAY()))"
    ActiveCell.Offset(1, 0).Range("A1").Select


    'This is the autosave feature and selects the last first row in column A that doesnt have data
    Application.OnTime Now + TimeValue("00:03:01"), "Save1"
    Range("A" & Rows.Count).End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select

    'This saves every microsoft excel workbook thats open on the desktop
    Dim wb As Workbook
    For Each wb In Workbooks
    wb.Save
    Next wb
    End Sub

  4. #4
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Is the suffix surely set in the scanner? This should be a sign Enter or Tab.

    Artik

Tags for this Thread

Posting Permissions

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