Trigger an event on Checkbox change

J

James

In my program I import information and add checkboxes to each row as
it is imported. I have to programmatically name each checkbox. If a
checkbox in one row is checked I need to call a procedure to copy that
row to another sheet. Unfortunately due to the fact that I can have a
hundreds of checkboxes on one sheet my code would become too large if
I create a procedure for each checkbox using the Change event.

The only way I could think of doing this is by using the change event
from the worksheet but is there a way to locate what cell was changed
that caused the event to be triggered? If I could locate the cell then
I could write some code to check to see if it was linked to the
checkbox.

If anyone knows how I could find the changed cell or has a better work
around I would appreciate it.
Thanks,
James
 
G

GJones

Hi James;

You can go into the worksheet object and use the following
example.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Range, Cancel As Boolean)

'Check the column

If ActiveCell.Column = 1 Then

'check if it is in the range you want
If ActiveCell.Row > 1 And ActiveCell.Row < 100 Then

'do your copy statement here.
'i used a message box for the example
MsgBox ""

End If


End If


End Sub





Thanks,

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top