# How to turn VBA Code to auto calculate sums in workbook?



## jerehall14 (Dec 15, 2022)

I copied and pasted a well used VBA code for the first time today to sum colored cells in a given range. The issue I am running into is that it wont auto calculate the sum. It only calculates if you click the cell with the formula and press enter manually. Again, I am not familiar with VBA and so I'm hoping there is a simple solution I can follow! Thanks


----------



## Flashbond (Dec 16, 2022)

```
Private Sub Worksheet_Change(ByVal Target As Range)
  Call yourFunction 'Your Sub name
End Sub
```


----------

