check box...in a cell...is it really?

Davers

Well-known Member
Joined
Sep 17, 2002
Messages
1,165
Hey everyone, this may be a silly question but... :confused: Is it possible to use terms like Offset with a checkbox? For instance, if I put a checkbox in cell A1...I know it's not really in cell A1, but is it aware of where it is in relation to the sheet? For instance if I put a check in the checkbox, and the check box is in cell A1, can I say something like:

Code:
If Worksheets("Sheet1").CheckBox1 = True Then
Cells.Offset.(0, 2).Font.Strikethrough = True
etc.

It would be nice if you could...

Thanks for any help...

Dave (y)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You need to put a "Form" checkbox on the sheet!
Then assign a macro to it. Do not test for the check being true!

Sub cbCheck()
'Sheet module code!
'For a "Form CheckBox" used on a sheet.

ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
Selection.Font.Strikethrough = True
End Sub

For a control checkbox:

Private Sub CheckBox1_Click()
'Sheet module code!
'For a "Control Tool Box CheckBox" used on a sheet.

If CheckBox1.Value = -1 Then
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
Selection.Font.Strikethrough = True
End If
End Sub
 
Upvote 0
If the Checkbox (Control Toolbox menu) is covering say cell B3, and the link cell is B3 (i.e. underneath the Checkbox) then the following will work (put the macro in the relevant sheet module):

Code:
Private Sub CheckBox1_Click()

With Worksheets("Sheet1")
  If Worksheets("Sheet1").CheckBox1 = True Then
   .Range("B3").Offset(0, 2).Font.Strikethrough = True
   Else
   .Range("B3").Offset(0, 2).Font.Strikethrough = False
  End If
End With
End Sub
Alternatively, drop the offset and directly format the target cell:
Code:
Private Sub CheckBox1_Click()

With Worksheets("Sheet1")
  If Worksheets("Sheet1").CheckBox1 = True Then
   .Range("D3").Font.Strikethrough = True
   Else
   .Range("D3").Font.Strikethrough = False
  End If
End With
End Sub
HTH

Mike
 
Upvote 0
I love this site!!!!! Man, thanks both of you very much!!! o_O

Have a good day,

Dave (y)
 
Upvote 0
In case you wanted to use the Form CheckBox and get it to cycle on and off use a soft switch:

Sub cbCheck()
'Sheet module code!
'For a "Form CheckBox" used on a sheet.
Static myClick

If myClick = "" Then
'ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
Selection.Font.Strikethrough = True
myClick = "Yes"
Else
ActiveCell.Select
Selection.Font.Strikethrough = False
myClick = ""
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

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