Date & Username Stamp Help

Rob1984

New Member
Joined
Jul 31, 2019
Messages
2
Hi,

I a pretty new to VBA and would like some support.

What I looking for is a piece of VBA code that will date stamp Column O Username Stamp Column P, based on the status in column K being changed to either - Resolved & Ignore/Resolved.

Ideally id like the O & P cells to be locked down an unchangeable - but this is only secondary - its a shared work book so not sure if locking the cells don would impact stability.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Rather than protecting cells VBA below prevents user from selecting any cells in columns O & P
The code is case sensitive
- assumes both "Resolved" and "Ignore/Resolved" are selected from dropdown in column K

There are 2 options for user name - use whichever one is better for you
Excel UserName = Application.UserName
Windows UserName = Environ$("Username")

Put code in the SHEET module (it will not work if placed anywhere else)
right-click on sheet tab \ click View Code \ paste code into the code window \ return to Excel with {ALT}{F11}

Code:
[COLOR=#006400][I]'[B]date stamp[/B] Column O [B]Username Stamp[/B] Column P, based on the status in column K being changed to either - [B]Resolved[/B] & [B]Ignore/Resolved[/B][/I][/COLOR]

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Usr As String, Cell As Range
        With Application
            Usr = .UserName         [COLOR=#006400][I]'Windows user Name:    Usr = Environ$("Username")[/I][/COLOR]
            
            If Not Intersect(Range("K2:K" & Rows.Count), Target) Is Nothing Then
                    .EnableEvents = False
                For Each Cell In Target
                    If Cell = "Resolved" Or Cell = "Ignore/Resolved" Then Cell.Offset(, 4).Resize(, 2) = Array(Date, Usr)
                Next Cell
                    .EnableEvents = True
            End If
        End With
End Sub

[COLOR=#006400][I]'[B]O[/B] & [B]P [/B]cells to be locked down and unchangeable[/I][/COLOR]

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
[COLOR=#006400][I]'prevent selecting any cells in columns O and P[/I][/COLOR]
    If Not Intersect(Range("O2:P" & Rows.Count), Target) Is Nothing Then Cells(Target.Row, "Q").Select
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,977
Members
452,540
Latest member
haasro02

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