select ActiveX checkbox adjacent cell

Krystal

New Member
Joined
Jan 11, 2016
Messages
11
Hi Hope you can help
is there a way to 'select' the adjacent cell for an activex checkbox, without referring to the cell by name.
the following code selects the correct cell, but I have to name change the code for every checkbox and I have dozens of them :eeek:

This is part of a bigger picture - I have 'Private Sub Worksheet_SelectionChange(ByVal target As Range)'
that works fine but will not execute unless the cell in the target column is selected. so I need to automatically select the cell that the checkbox is in then select the cell in the target column which is offset(0,2)

stating the obvious in the example I have given you the checkbox is named 'TotalPaid3'

Code:
If TotalPaid3.Value Then
   TotalPaid3.TopLeftCell.Offset(0, 0).Select
   TotalPaid3.TopLeftCell.Offset(0,2).Select
 Else
   TotalPaid3.TopLeftCell.Offset(0, 0).Select
   TotalPaid3.TopLeftCell.Offset(0, 2).Select


End If
[code/]
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi Dave thanks for your quick response.
I have checked it out and as far as I can tell 'Application.Caller' only works with form check boxes not activex checkboxes. that is unless I am doing something else wrong
 
Upvote 0
Possibly something like this,

Code:
Private Sub CheckBox1_Click()
    With ActiveSheet.CheckBox1
        If .Value Then
            Range(.TopLeftCell, .TopLeftCell).Offset(0, 2).Select
        Else
            Range(.TopLeftCell, .TopLeftCell).Offset(0, 4).Select
        End If
    End With
End Sub
 
Upvote 0
Sorry for the late reply. please excuse my ignorance, I am new to this. Doesn't your suggestion mean that I would need to replace 'Checkbox1' with the name of my checkboxes. eg 'TotalPaid3', 'TotalPaid4' etc for all checkboxes
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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
Back
Top