How to refer to "self"?

C

CS Imam

Hello,

This is a simple question, but I have searched high and low and didn't
find the answer. I think I am not thinking about the problem in the
right way.

I have a set of rows with data on each row. I would like to put a
checkbox on each row at the beginining, and when the user clicks on a
row's checkbox, for a macro to be activated to run validation routines
on the data of that row alone.

Here is my question: in the macro that is activated for the
checkboxes, how do I find out the row of the checkbox? Is there an
equivalent to Java/C++/C#'s "this" pointer or something of that
nature, that would allow me to refer to the particular checkbox's
"self"? To ask it "what row are you on"?

confused.
 
B

Bob Phillips

Why bother with the checkbox, you only seem to need it when selected. Why
not just use the doubleclick event on column A, as an alternative?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

Dave Peterson

If it's a checkbox from the Forms toolbar, you could assign the same macro to
each of the checkboxes and then use something like:

Option Explicit
Sub testme()
Dim CBX As CheckBox
Set CBX = ActiveSheet.CheckBoxes(Application.Caller)
If CBX.Value = xlOn Then
'it's checked
MsgBox CBX.TopLeftCell.Row
Else
'it's not checked
End If
End Sub

If it's a checkbox from the control toolbox toolbar, you'd know since your code
would be in the checkbox1_click event.

Option Explicit
Private Sub CheckBox1_Click()
MsgBox Me.CheckBox1.TopLeftCell.Row
End Sub

=======
But I wouldn't use a checkbox.

I'd add a button to row 1. Freeze the panes so that row 1 is always visible,
then process the row with the activecell.

The instructions would be something like:
Select the row
click the button
 
Top