Insert formula if CheckBoxes.Value = xlOn

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
Hi
I want to insert a formula in the cell left to a check box, if the CheckBoxes.Value = xlOn :

Sub test()


For i = 53 To 102
If ActiveSheet.CheckBoxes(i).Value = xlOn Then
ActiveSheet.CheckBoxes(i).TopLeftCell.Offset(1, 0).Formula = ("=2+2")
End If

Next i
End Sub

My problem: When there is an = sign in the formula (e.g. ("=2+2")), the formula is inserted to all the cells, eaven if the check boxes = xlOf.

If i remove the = sign (e.g. ("2+2")) the formula is inserted only in the cells to left of the check boxes = xlOn. In other word the expected behaviour. Any idea?

Eivind
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Actually, as it stands, your code inserts the formula in the cell below the checkbox, not in the cell to the left of it. So, for example, if the checkbox lies within the B2, the formula will be inserted in B3, not A2. Is this your intent? Could this be the issue?
 
Upvote 0
Actually, as it stands, your code inserts the formula in the cell below the checkbox, not in the cell to the left of it. So, for example, if the checkbox lies within the B2, the formula will be inserted in B3, not A2. Is this your intent? Could this be the issue?

That was just to compensate for another thing.

To illustrate my problem (without check boxes):
https://youtu.be/2WFY9CdyD5w

https://drive.google.com/drive/folders/12SQWhjNeHtKNpscrsa3I4SQPXxjwqi7h?usp=sharing
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,749
Messages
6,180,727
Members
452,995
Latest member
isldboy

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