Automatically Update the Username After Each New Entry

Magdoulin

Board Regular
Joined
Jan 11, 2013
Messages
73
Hi guys,

I have project with Template sheet that will be copied with the same table structure from time to time
The end user will pick one of them and go to log his / her data
I need to specify column in the Template just to read the user GTI and log it automatically after each row update by new entry
I’ve written the below code but apparently it changes the value of the entire usernames column cells every time different user update any cell in Column B
I need it to be smart to change only the last updated row by this specific end user

Code:
Dim rw As Range
Sub forEachWs()
For Each rw In ActiveSheet.Rows
If ActiveSheet.Cells(rw.Row, 2).Value <> "" Then
ActiveSheet.Cells(rw.Row, 6).Value = Environ("UserName")
End if
Next rw
End Sub

On the other hand, this one doesn’t work the way I want it to do, I need the following, if the end user update A8 with some value, to update A9 with the GTI username automatically, like the cell underneath, obviously it updates the rest of the cells in the whole column with the GTI value, I need one cell only which is the one under the last cell update

Code:
Dim rw As Range
Sub forEachWs()
For Each rw In ActiveSheet.Rows
If ActiveSheet.Cells(rw.Row, 8).Value <> "" Then
ActiveSheet.Cells(rw.Row + 1, 8).Value = Environ("UserName")
End If
Next rw
End Sub
 
Glad to help & thanks for the feedback
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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