Finding Row number of a checkbox

  • Thread starter Thread starter Bill D.
  • Start date Start date
B

Bill D.

I want to determine the row number of a checkbox when it is checked. I
have the following code:

MyRoutineCheckBox:

If ActiveSheet.CheckBoxes(buttonclicked).Value = xlOn Then
Cells(vSubTotalRow, vColumn) = Cells(vSubTotalRow, vColumn)+ Cells(vRow,
vColumn)
If ActiveSheet.CheckBoxes(buttonclicked).Value = xlOff Then
Cells(vSubTotalRow, vColumn) = Cells(vSubTotalRow, vColumn)- Cells(vRow,
vColumn)
Return

Buttonclicked is the name of the checkbox determined by: buttonclicked =
Application.Caller Now vRow is determined from a SelectCase routine.
This is very long since there are more than 100 checkboxes on the sheet.
I want the vRow to be determined in the subroutine based on which
checkbox is ON.

I know somehow I need to use TopLeftCell.Row but can not figure out
how. All my atempts end with an Object Required error.

Thanks for any help.

Bill

There are 10 types of people; those that understand binary and those
that don't.
 
With Activesheet.checkboxes(buttonclicked)
If .Value = xlOn Then
Cells(vSubTotalRow, vColumn) = Cells(vSubTotalRow, vColumn) _
+ Cells(.TopLeftCell.row,vColumn)
ElseIf .Value = xlOff Then
Cells(vSubTotalRow, vColumn) = Cells(vSubTotalRow, vColumn) _
- Cells(.TopLeftCell.Row,vColumn)
End if
End With
 
Tom, thanks

Much more elegant than the hack I came up with.

to wit:

vRow = ActiveSheet.CheckBoxes(buttonclicked).TopLeftCell.Row

I've got to understand when to use the With/End With statement.
Thanks again

Bill

There are 10 types of people; those that understand binary and those
that don't.
 

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

Back
Top