Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

Passing Parameters

Posted by Bob on August 28, 2001 2:07 PM
Anyone know if it is possible to pass a parameter to the code in
a sheet? In other words, If a click event happens, then Parameter
= True.

I tried:

Sub Review_Click()
MyParm = True
Call Worksheet_SelectionChange(MyParm)
End sub

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range, ByVal MYPARM as Boolean)
If MyPARM = True then
Do some Code
Don't do my Code
End If
End sub

But it didn't work.

Check out our Excel VBA Resources

Re: Passing Parameters

Posted by Russell Hauf on August 28, 2001 3:02 PM
You can just use a global variable. Above your Worksheet_SelectionChange event, just declare MyParm:

Private MyParm as Boolean

Then in your click event, you can set it.

Sub Review_Click()
End Sub

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If MyParm Then
' Do Something
' Do something else
End If

End Sub

Hope this helps,


This archive is from the original message board at
All contents © 1998-2004
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.