L
Legacy 347657
Guest
Hi
I currently have a macro that automatically inputs a users name/ID and a datestamp in a cell (Column K) when a checkbox in column J is ticked. I've added the VBA text below for reference (this includes script to unlock and lock the worksheet as well as it is a password protected file).
This is a very useful macro, however I would like to add the following functions and am wondering if someone can help me.
Here's the text - thanks very much in advance for any help!
Sub Process_CheckBox()
Dim cBox As CheckBox
Dim LRow As Integer
Dim LRange As String
LName = Application.Caller
Set cBox = ActiveSheet.CheckBoxes(LName)
ActiveSheet.Unprotect Password:="signoff"
'Find row that checkbox resides in
LRow = cBox.TopLeftCell.Row
LRange = "K" & CStr(LRow)
'Change date in column K, if checkbox is checked
If cBox.Value > 0 Then
ActiveSheet.Range(LRange).Value = Application.UserName & " " & Date
ActiveSheet.Protect Password:="signoff"
'Clear date in column K, if checkbox is unchecked
Else
ActiveSheet.Range(LRange).Value = Null
ActiveSheet.Protect Password:="signoff"
End If
End Sub
I currently have a macro that automatically inputs a users name/ID and a datestamp in a cell (Column K) when a checkbox in column J is ticked. I've added the VBA text below for reference (this includes script to unlock and lock the worksheet as well as it is a password protected file).
This is a very useful macro, however I would like to add the following functions and am wondering if someone can help me.
- How do I change this so that the macro works with an ActiveX checkbox (rather than a form checkbox) - so the checkboxes can be moved and sized with cells, so I can use filters etc?
- Can I add to this macro so that when the checkbox is ticked, whatever is in column F is copied and value-pasted into column L?
- Can I add another checkbox (to column H) - so there are more than checkbox in a row - that puts username and datestamp in column I when ticked?
Here's the text - thanks very much in advance for any help!
Sub Process_CheckBox()
Dim cBox As CheckBox
Dim LRow As Integer
Dim LRange As String
LName = Application.Caller
Set cBox = ActiveSheet.CheckBoxes(LName)
ActiveSheet.Unprotect Password:="signoff"
'Find row that checkbox resides in
LRow = cBox.TopLeftCell.Row
LRange = "K" & CStr(LRow)
'Change date in column K, if checkbox is checked
If cBox.Value > 0 Then
ActiveSheet.Range(LRange).Value = Application.UserName & " " & Date
ActiveSheet.Protect Password:="signoff"
'Clear date in column K, if checkbox is unchecked
Else
ActiveSheet.Range(LRange).Value = Null
ActiveSheet.Protect Password:="signoff"
End If
End Sub