# Automatically update cell.value as long as a ActiveX checkbox is checked - excel 365 on WINDOWS

#### excel_lelkes

##### New Member
C2.value is updated when a button is clicked.
My wish is that so long cbox1 is checked O17.value = C2.value

Code:
``````Private Sub cbox1_Click()
If Me.cbox1.onValue = True Then
Sheet1.Range("O17").Value = Sheet1.Range("C2").Value
End If

End Sub``````
With this code I need everytime click the checkbox

Please help me with a code that updates O17.Value automatically. I hope I could explain so you can understand what I want to do....

Peter from Sweden, using Excel-365 on Windows

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

#### James006

##### Well-known Member
Hello,

Have you set a cell link for your ActiveX checkbox ... ?

#### James006

##### Well-known Member

In cell O17, you could have following formula:

=IF(A1,C2,"")

Hope this will help

#### excel_lelkes

##### New Member
I didn´t know that I have to do that. I don´t know how, so now I'll google it and try

Regards
Peter

#### excel_lelkes

##### New Member
I didn´t know that I have to do that. I don´t know how, so now I'll google it and try

Regards
Peter
I hope I didn´t offended you James, but for med the best way to learn, is to understand! That's why I want to google so I can learn  #### excel_lelkes

##### New Member
With James tips on
, I have solved the problem as follows:
• 4 checkboxes linked to A10, A11, A12, and A13
• this code
Code:
``````Sub resultQ()If Sheet1.Range("A10").Value = True And Sheet1.Range("A11").Value = False And Sheet1.Range("A12").Value = False And Sheet1.Range("A13").Value = False Then
Sheet1.Range("O17").Value = Sheet1.Range("C2").Value
ElseIf Sheet1.Range("A10").Value = True And Sheet1.Range("A11").Value = True And Sheet1.Range("A12").Value = False And Sheet1.Range("A13").Value = False Then
Sheet1.Range("O18").Value = Sheet1.Range("C2").Value - Sheet1.Range("O17").Value
ElseIf Sheet1.Range("A10").Value = True And Sheet1.Range("A11").Value = True And Sheet1.Range("A12").Value = True And Sheet1.Range("A13").Value = False Then
Sheet1.Range("O19").Value = Sheet1.Range("C2").Value - (Sheet1.Range("O17").Value + Sheet1.Range("O18").Value)
ElseIf Sheet1.Range("A10").Value = True And Sheet1.Range("A11").Value = True And Sheet1.Range("A12").Value = True And Sheet1.Range("A13").Value = True Then
Sheet1.Range("O20").Value = Sheet1.Range("C2").Value - (Sheet1.Range("O17").Value + Sheet1.Range("O18").Value + Sheet1.Range("O19").Value)

End If
End Sub``````

• worsheet change event:
Code:
``````Private Sub Worksheet_Change(ByVal Target As Range)
Call resultQ
End Sub``````
It's maybe not the most elegant solution, but it works for me, at least localt on my computer....

Regards
Peter

You are welcome