Reputation: 263
The right click event I have created displays an error message "Procedure declaration does not match description of event or procedure having the same name".
My goal is to right click on a cell and have the count of a column from another sheet input into the target cell.
What is my error that I am missing?
Sub Worksheet_BeforeRightClick(ByVal Target As Range)
Dim wb As Workbook
Dim i As Long
Set wb = Workbooks("Calc.xlsm")
EventState = Application.EnableEvents
Application.EnableEvents = True
Target.Address = Application.count(wb.Sheets("Carrier").Range("O:O"))
End Sub
Upvotes: 1
Views: 132
Reputation: 29332
The error message is pretty clear. Your event handler's prototype does not equal what Excel wants it to be. change it into:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
You cannot change the signature of event handlers.
Upvotes: 1