Inserting date based on status of load

sonofagunn123

New Member
Joined
May 27, 2022
Messages
5
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hopefully someone in here can help me.. I am currently trying to update our Shipping/ Load tracker and I am running into an issue. I am trying to make it to where when column N shows as "Packing" it enters the date and time into column P and when it shows "Packed" enters the date and time into column Q. The problem is once I change it from packing to packed it erases the previous date and time stamp. thanks in advance for yall's help.
Capture.PNG
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hopefully someone in here can help me.. I am currently trying to update our Shipping/ Load tracker and I am running into an issue. I am trying to make it to where when column N shows as "Packing" it enters the date and time into column P and when it shows "Packed" enters the date and time into column Q. The problem is once I change it from packing to packed it erases the previous date and time stamp. thanks in advance for yall's help. View attachment 71378
Since it's a VBA problem and I'm quite layman at it - I think of an idea and then try to find right VBA method to execute that.

What I can tell is that it can be solved by add an IF statement where it skips changing information in Column P if input in Column N anything but "Packing"

Post that part of VBA here, where it inputs Date & Time stamp in Column P on the basis of Input in Column N and someone shall help you out.
 
Upvote 0
Since it's a VBA problem and I'm quite layman at it - I think of an idea and then try to find right VBA method to execute that.

What I can tell is that it can be solved by add an IF statement where it skips changing information in Column P if input in Column N anything but "Packing"

Post that part of VBA here, where it inputs Date & Time stamp in Column P on the basis of Input in Column N and someone shall help you out.
The if statement that i have is =IF(N128="Packing",NOW(),"") , =IF(N128="Packed",NOW(),"").. I dont have a vba for this was hoping someone here might know of one or have a formula that will work.
 
Upvote 0
How are the values in column N being updated?
Is someone manually doing that?

If so, then we want to use "Worksheet_Change" event procedure code to automatically run when column N is automatically being updated.

To do this, right-click on the sheet tab name at the bottom of your screen, select "View Code", and paste this code in the VB Editor window that pops up.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
'   See if any cells in column N updated
    Set rng = Intersect(Target, Range("N:N"))
    If rng Is Nothing Then Exit Sub
    
'   Loop through updated cells in column N
    For Each cell In rng
        Select Case cell.Value
            Case "Packing"
                Range("P" & cell.Row).Value = Now()
            Case "Packed"
                Range("Q" & cell.Row).Value = Now()
        End Select
    Next cell
    
End Sub
 
Upvote 0
Solution
How are the values in column N being updated?
Is someone manually doing that?

If so, then we want to use "Worksheet_Change" event procedure code to automatically run when column N is automatically being updated.

To do this, right-click on the sheet tab name at the bottom of your screen, select "View Code", and paste this code in the VB Editor window that pops up.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
   
'   See if any cells in column N updated
    Set rng = Intersect(Target, Range("N:N"))
    If rng Is Nothing Then Exit Sub
   
'   Loop through updated cells in column N
    For Each cell In rng
        Select Case cell.Value
            Case "Packing"
                Range("P" & cell.Row).Value = Now()
            Case "Packed"
                Range("Q" & cell.Row).Value = Now()
        End Select
    Next cell
   
End Sub
This worked perfectly thank you very much! you saved me quite the headache!
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,221,444
Messages
6,159,914
Members
451,603
Latest member
SWahl

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