Reputation: 13
I have code that populates cells when double clicked on the cell. Here it is:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("C10:C19", "D10:D19", "E10:E19")) Is Nothing Then
Cancel = True
Target.Formula = Date
End If
End Sub
The code was working fine until I added "E10:E19"
then it gives me a compile error saying wrong number of arguments or invalid property assignments
and then it highlights the first line of code Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Full disclosure: I am a total noob at this so any fixes or advice please explain like I am 5 years old.
Upvotes: 1
Views: 5372
Reputation: 12499
Try this
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, [C10:C19, D10:D19, E10:E19]) Is Nothing Then
Cancel = True
Target.Formula = Date
End If
End Sub
"C10:C19", "D10:D19", "E10:E19"
Range should be one string not multiple strings
Examnple "C10:C19, D10:D19, E10:E19"
Upvotes: 2