Date, Time and Name of last modification in specific cell range

kingnitwit

New Member
Joined
Apr 25, 2018
Messages
4
Hi,

I'm quite new to VBA and having trouble figuring out how to make this work.
I have an excel sheet with information linked to specific accounts. When someone modifies the information in that specific row, I want the cells in a specific column to show who has last modified that specific row/cell range and on which date and time.

I have found the following code here which creates a function for date and time, but no name:
Code:
Public Function Lastmodified(c As Range)


Lastmodified = Now()


End Function

I then found this code here, which provides me with Date, Time and user, but only for the entire sheet, rather than a specific range.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Sh.Range("T56") = "Revised: " & Format(Date, "mm/dd/yyyy") & " at " & Format(Time, "hh:mm AMPM") & " by " & Application.UserName
End Sub

Could you help me out with a code that will provide me with date, time and user per a certain range/row?
Any help would be greatly appreciated :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the forum.

A small change to the first function might be:

Code:
Public Function Lastmodified(c As Range)


Lastmodified = Application.Username & ": " & Now()


End Function
 
Upvote 0
We aim to please. :biggrin:
 
Upvote 0
I noticed that using the Application.Username inserts the name that the computer is registered as (if it makes sense). Is there a way to make it only show the first name or the initials?
 
Upvote 0
Application.Username returns whatever is shown in the User information in Excel. If you want the Windows login name, you can use Environ("username") instead.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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