Adding username if X is in a certain cell

dh231

New Member
Joined
Sep 10, 2020
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
I am trying to have a checklist that when a user checks off an item it logs their name in the cell below.
My code is as follows but it does nothing.:
Code:
If Target.Column = 2 Then
    If Target = "X" Or Target = "x" Then
        Application.EnableEvents = False
            Target.Offset(1, 0) = Environ("Username")
        Application.EnableEvents = True
    End If
End If

End Sub

This is a sample of my worksheet. Any assistance will be much appreciated.

TASKDay1Day2
Task 1X
Initialname
Task 2X
Initialname
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
How about
VBA Code:
Target.Offset(1, 0).value

Instead of

VBA Code:
Target.Offset(1, 0)
 
Upvote 0
Hi & welcome to MrExcel.
That code is working on column B only, what columns should it work on?
Also what is the name of the procedure, as you haven't supplied that?
 
Upvote 0
Sorry, missed a line:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 2 Then
    If Target = "X" Or Target = "x" Then
        Application.EnableEvents = False
            Target.Offset(1, 0).Value = Environ("Username")
        Application.EnableEvents = True
    End If
End If

End Sub

I would like it to work on all columns B:AF

Tried the
VBA Code:
Target.Offset(1, 0).Value
Nothing changed.
 
Upvote 0
Ok, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("B:AF")) Is Nothing Then
      If LCase(Target) = "x" Then
         Application.EnableEvents = False
         Target.Offset(1).Value = Environ("Username")
         Application.EnableEvents = True
      End If
   End If
End Sub
 
Upvote 0
Where is the code located? Is it in the correct sheet module?
 
Upvote 0
I think so. I have only 1 workbook open, 1 sheet. It's listed under Modules as Module1
 
Upvote 0
It needs to go in the Sheet module, not a regular module.
In the VB Editor double click the sheet in the project window & paste the code into the code window that opens up.
 
Upvote 0
OMG - lol thank you very much. This looks to be working wonderfully!!
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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