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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,223,723
Messages
6,174,107
Members
452,544
Latest member
aush

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