Checkbox that enters username into cell to the right

Anonymous
2015-07-11T22:08:33+00:00

Hello Everyone, I have a spreadsheet, and on some of the worksheets there are checkboxes in in the O column. When checked the VBA code I have should automatically put the persons username in the P column of the same row in which the box was checked.

This worked excellent when I had only one worksheet. Now that I have multiple sheets I am getting an error message.

The code is:

[code]

Sub Process_CheckBox()

Dim cBox As CheckBox

Dim LRow As Integer

Dim LRange As String

LName = Application.Caller

Set cBox = ActiveSheet.CheckBoxes(LName)

'Find row that checkbox resides in

LRow = cBox.TopLeftCell.Row

LRange = "P" & CStr(LRow)

'Change date in column B, if checkbox is checked

If cBox.Value > 0 Then

ActiveSheet.Range(LRange).Value = Environ("USERNAME")

'Clear date in column B, if checkbox is unchecked

Else

ActiveSheet.Range(LRange).Value = Null

End If

End Sub

[/code]

and the error message I get is :

Run-time error '1004':

Application-defined or object-defined error

The Debugger highlights this line in the code:

ActiveSheet.Range(LRange).Value=Null

The workbook can be viewed here....

https://onedrive.live.com/redir?resid=1133973B98CD486!340&authkey=!AHIS2AnLOd7QF7w&ithint=file%2cxlsm

Help?!?!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more