Easy Checkbox control help please

Armster

Board Regular
Joined
Jul 26, 2007
Messages
63
Silly newbie question really :)

Basically i have the following checkbox in a script I have wrote, I need it to place (preferably in the name of the check box, though in the adjacent cell will do just as well) the current Date, when the checkbox is checked.

I get an error on the .onaction part

can you point me to the right direction :)

thanks

Dave

Code:
    ActiveSheet.CheckBoxes.Add(Cells(irow, 4).Left, Cells(irow, 4).Top, 10, 10).Select
        With Selection
        .Placement = xlMove
        .PrintObject = True
        .Value = xlOff
        .Characters.Text = "Form Response"
'       .OnAction = "customize"
        .OnAction = (Cells(irow, 5) = Date)
        .ShapeRange.Width = 150
        End With
    irow = irow + 1
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You need to write your customize procedure:

Code:
Sub customize()
    ActiveSheet.CheckBoxes(Application.Caller).TopLeftCell.Offset(0, 1).Value = Date
End Sub
 
Upvote 0

Armster

Board Regular
Joined
Jul 26, 2007
Messages
63
the customize macro is commented out as I was thinking that using the .OnAction command could be called or another subcommand of the checkbox to make the Date be place in the adjacent cell ?
 
Upvote 0

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
The OnAction property expects the name of a macro, not the actual macro code. Did you try setting it to "customize" and adding the procedure I posted?
 
Upvote 0

Armster

Board Regular
Joined
Jul 26, 2007
Messages
63
yes it worked, many thanks. Now I can send it off to my director and keep him happy for a day or 2
 
Upvote 0

Forum statistics

Threads
1,191,204
Messages
5,985,263
Members
439,953
Latest member
suchitha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top