Recording user when changing Active Row

Foynxter1

New Member
Joined
Sep 29, 2016
Messages
40
Help please.
I found this code and have adjusted slightly to fit my needs.
My spreadsheet is called "Additional Charges" and I want to record any user that makes a change anywhere on the active row.

Code is :
'Set the user who modified the record
Dim ThisRow As Long ' make sure to declare all the variables and appropiate types
ThisRow = Target.Row
'protect Header row from any changes
If (ThisRow = 1) Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Header Row is Protected."
Exit Sub
End If
If Target.Column >= 1 And Target.Column <= 30 Then
MsgBox Target.Column
Dim sOld As String, sNew As String
sNew = Target.Value 'capture new value
With Application
.EnableEvents = False
.Undo
End With
sOld = Target.Value 'capture old value
MsgBox sOld & "Old"
Target.Value = sNew 'reset new value
MsgBox sNew & "New"
If sOld <> sNew Then
Range("E" & ThisRow).Value = Environ("username")
End If
Application.EnableEvents = True
End If

For some reason the code is only recognising column 1 (and recording if column 1 changes) but does not seem to recognise any other column.
I am probably missing something obvious but Any help much appreciated. Thanks
 
When a script does not work you need to explain what it did or did not do.

I test all my scripts. You said if any cell have a change in value to record UserName in column E
 
Last edited:
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, I tried the change on several cells but still did not record the username - except if it's column 1. Frustrating. Thanks
 
Upvote 0
Take my script. Put it in a blank sheet and then if you change any cell value on any row the username will be put in column "E" of same row. I test all my scripts and this works perfectly.

Now if you have added my script to some other script you have it will not work.
Show me the script you installed in your sheet.
 
Upvote 0
I certainly will - I have no doubt that you have checked your script so quite likely a conflict with other code which I am not seeing. Let me check it and I will let you know. Thanks
 
Upvote 0
what worksheet or module holds the VBA Macro that is to run from
 
Upvote 0
Did you install the script like this as of my previous instructions:

This is an auto sheet event scrip
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tabSelect View Code from the pop-up context menu
Paste the code in the <acronym title="visual basic for applications">VBA</acronym> edit window


This is not a Module script
 
Upvote 0
Hi - As you suggested I set up the code in a new sheet and it worked fine. There is obviously a little investigation I need to do to find and eradicate the conflict within the additional code - but it gives me a good place to start.
Thanks your help.
 
Upvote 0
Glad I was able to help you. Come back here to Mr. Excel next time you need additional assistance.
Hi - As you suggested I set up the code in a new sheet and it worked fine. There is obviously a little investigation I need to do to find and eradicate the conflict within the additional code - but it gives me a good place to start.
Thanks your help.
 
Upvote 0
The script I provided is a sheet event script. If you have more then one sheet event script in your sheet you should show them to me. Maybe I can sort out the conflicts.
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,156
Members
452,385
Latest member
Dottj

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