Trouble Repeating VBA Code

Melroy

New Member
Joined
Jul 11, 2019
Messages
2
Hello,
I'm new to VBA coding.
I found a very useful code that allows me to produce a checkmark when I double click on the task I've just completed. However, for some reason, I can't repeat the action. See code below:

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A10:A41")) Is Nothing Then
If Target.Count > 1 Then Exit Sub
If Target.Value = "?" Then Target.Value = "blank" Else: Target.Value = "?"
End If
End Sub[/FONT]

I need to repeat the above code in three other columns on the same sheet (e.g. F10:F18, L10:L21 and P10:P15). I've searched the internet and found a few solutions, but each time a use them, I get errors that I can't seem to resolve.
Can you kindly provide me with some direction on how to get this to work the way I need it to?
Thank you!
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,080
Office Version
365
Platform
Windows
You can use this line instead of current one:

Code:
If Not Intersect(Target, Union(Range("A10:A41"), Range("F10:F18"), Range("L10:L21"), Range("P10:P15"))) Is Nothing Then
 

Melroy

New Member
Joined
Jul 11, 2019
Messages
2
Brilliant - it worked!!!
Thank you.
Just so I add to my learning - what does the "union" formula do?
 

Watch MrExcel Video

Forum statistics

Threads
1,099,774
Messages
5,470,702
Members
406,718
Latest member
waseem11

This Week's Hot Topics

Top