VBA to populate asset, location, time in, time out. And update column in table

rdo556

New Member
Joined
Dec 26, 2013
Messages
5
Hello all,

I know MS Access would be better for this but excel is what I have to work with.

I am trying to create a macro that will allow me to scan the bar code serial number of an asset and log it in cell A2, then scan the location Out to B2, Check out, to C2, and Check in, to D2, Location In to E2. next scanned asset would go in B2 , C2, ect...

I would also like for it to update a table field in another worksheet when the asset is checked out or checked In.

Worksheet "Inventory" Table "tblData" column "Location"

I found this in my search and it almost works, minus the location fields.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)    '   Code goes in the Worksheet specific module
    Dim rng As Range
    Dim strTracking As String
        '   Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
        Set rng = Target.Parent.Range("A:A")
        '   Only look at single cell changes
            If Target.Count > 1 Then Exit Sub
        '   Only look at that range
            If Intersect(Target, rng) Is Nothing Then Exit Sub
        '   Action if Condition(s) are met (do your thing here...)
            Application.EnableEvents = False
            '   Look for the Tracking #
                strTracking = Columns("A").Find(Target.Value).Address
            '   If the Tracking # exists, then time stamp the original and delete the Out scan
                If strTracking <> Target.Address Then
                Range(strTracking).Offset(, 2).Value = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")
                Target.EntireRow.Delete
                ActiveCell.Offset(-1, 0).Select
            Else
                '   If the Tracking # doesn't exist then enter it and the In time stamp
                    Target.Offset(0, 1).Value = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")
                End If
            Application.EnableEvents = True
            
End Sub


Serial NumberLocation OutChecked OutChecked InLocation In
B-005ROTHE8/22/2017 16:578/23/2017 4:51TOOL CRIB
GM-011CAL-TECH8/22/2017 16:57
P-067MACHINE 158/22/2017 16:578/23/2017 8:45TOOL CRIB

<tbody>
</tbody>


Thanks in advance for any and all assistance.

Ryan
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,130
Messages
6,123,220
Members
449,091
Latest member
jeremy_bp001

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