Hi Yasser,
YasserKhalil wrote: ↑15 Jan 2022, 09:24
... throws an error that the argument not optional. I tried to add the range and boolean value True as arguments but it displayed as red which refers to an error in syntax
I think the syntax on things like Application.Run can be a bit tricky, but it should work
Example:
This in your worksheet code module
Code: Select all
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Let Target.Value2 = "This cell ya double clicked yaz"
End Sub
Then these sort of things should work in a normal code module to set that macro above off
Code: Select all
' https://eileenslounge.com/viewtopic.php?f=30&t=37685
Sub CallMeBeautifulPrivates()
Dim bCancel As Boolean
Application.Run Macro:="'Sheet1.Worksheet_BeforeDoubleClick'", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:=" Sheet1.Worksheet_BeforeDoubleClick ", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="Sheet1.Worksheet_BeforeDoubleClick", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="Sheet1.Worksheet_BeforeDoubleClick ", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run "Sheet1.Worksheet_BeforeDoubleClick ", ActiveCell, bCancel
Application.Run Macro:="'Book1.xls'!Sheet1.Worksheet_BeforeDoubleClick ", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="'" & ThisWorkbook.Path & "\Book1.xls'!Sheet1.Worksheet_BeforeDoubleClick ", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="'" & ThisWorkbook.Path & "\Book1.xls'! Sheet1.Worksheet_BeforeDoubleClick ", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="'" & ThisWorkbook.Path & "\Book1.xls'!'Sheet1.Worksheet_BeforeDoubleClick'", Arg1:=ActiveCell, Arg2:=bCancel
Application.Run Macro:="'" & ThisWorkbook.Path & "\Book1.xls'! 'Sheet1.Worksheet_BeforeDoubleClick'", Arg1:=ActiveCell, Arg2:=bCancel
End Sub
' Ref
' https://excelfox.com/forum/showthread.php/2404-Notes-tests-Application-Run-OnTime-Multiple-Variable-Arguments-ByRef-ByVal?p=11870&viewfull=1#post11870
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime
' https://web.archive.org/web/20180101022746/http://excelmatters.com/2017/04/07/passing-arguments-byref-using-run/#comment-205985
Alan
You do not have the required permissions to view the files attached to this post.
I am having difficulty logging in with this account just now.
You can find me at DocAElstein also