tags:

views:

513

answers:

1

Hi,

How to pass argument to a method which is registered with the onAction event in excel VBA.

The code is have is:

With ActiveSheet.CheckBoxes.Add(rCell.Left, rCell.Top, rCell.Width, rCell.Height)
        .Interior.ColorIndex = xlNone
        .Caption = ""
        .OnAction = "CheckboxChange"
End With

I want to pass the "rCell" to the "CheckboxChange" sub routine. Any way to do that. Basically I want to know the cell in which the checkbox was present in the CheckboxChange sub routine.

A: 

Change this:

.OnAction = "CheckboxChange"

To this:

.OnAction = "'CheckboxChange""" & rCell & """'"

""" = 3 double quotes

"""'" = 3 double quotes & 1 single quote & 1 double quote

guitarthrower