-
-
I was wondering can there be two "Private Sub Worksheet_BeforeDoubleClick" on the same worksheet? If not can this "Private Sub Worksheet_SelectionChange" used for checkmarks be incorporated into this "Private Sub Worksheet_BeforeDoubleClick" used to input dates? Both of the following codes are on worksheet named "Input".
[VBA] Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CheckmarkCells As Range
Set CheckmarkCells = Range("A20,A22,A24,A28,A30,A37,A41,E45,E47,E49,A62,A64,A66,A68")
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, CheckmarkCells) Is Nothing Then
Me.Unprotect Password:="password"
If Target.Font.Name = "Marlett" Then
Target.ClearContents
Target.Font.Name = "Arial"
' Range("G16").Select
Target.Offset(0, 1).Select
Else
Target.Value = "a"
Target.Font.Name = "Marlett"
' Range("G16").Select
Target.Offset(0, 1).Select
End If
Me.Protect Password:="password"
End If
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E5,E15,T60")) Is Nothing Then
Target.Value = Date
Cancel = True
End If
End Sub[/VBA]
Best regards,
Charlie
-
There cannot be two, but it can do two things, either to the same Target, or it can test Target and do one of two things depending upon what the range is.
-
Thanks "xld" for responding....do you have an example?
Regards,
Charlie
-
Give us the two things you want to do and I will construct one.
-
Here's what I wanting to do....I want the user to be able to tab through the "worksheet form" and the cells that would contain checkmarks and the current date (currently run by a doubleclick event) without removing the checkmarks or dates. I want the checkmarks and dates to run off the doubleclick macro. I think this would resolve my issue...does this make sense?
Regards,
Charlie
-
"XLD" here's a copy of the worksheet form with Private Sub Worksheet_BeforeDoubleClickfor the dates, if this helps you help me?
Regards,
Charlie
-
"XLD" I came up with this coding which seems to work and tab through the input cells without removing the checkmarks. Take a look at the workbook and see what you think.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E5,E15,T60")) Is Nothing Then
Me.Unprotect Password:="password"
Target.Value = Date
Cancel = True
End If
Me.Protect Password:="password"
If Not Intersect(Target, Range("A20,A22,A24,A28,A30,A37,A41,E45,E47,E49,A62,A64,A66,A68")) Is Nothing Then
Me.Unprotect Password:="password"
If Target.Font.Name = "Marlett" Then
Target.ClearContents
Target.Font.Name = "Arial"
Target.Offset(0, 1).Select
Else
Target.Value = "a"
Target.Font.Name = "Marlett"
Target.Offset(0, 1).Select
End If
Me.Protect Password:="password"
End If
End Sub
Best Regards,
Charlie
-
New issue came up; when I doubleclick to remove the dates, the dates stay in the cell????
-
Solved my issue with the following code;
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E5,E15,U60")) Is Nothing Then
Me.Unprotect Password:="password"
If Target.Value = Date Then Target.Value = "" Else Target.Value = Date
Cancel = True
End If
Me.Protect Password:="password"
If Not Intersect(Target, Range("A20,A22,A24,A28,A30,A37,A41,E45,E47,E49,A62,A64,A66,A68")) Is Nothing Then
Me.Unprotect Password:="password"
If Target.Font.Name = "Marlett" Then
Target.ClearContents
Target.Font.Name = "Arial"
Target.Offset(0, 1).Select
Else
Target.Value = "a"
Target.Font.Name = "Marlett"
Target.Offset(0, 1).Select
End If
Me.Protect Password:="password"
End If
End Sub
Regards,
Charlie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules