I cant make my code run in Excel VBA (office 365).
I would like to make this code to run after any cell is changed by user or code:
`
Sub Workbook_SC()
Dim var1 As Double
Application.EnableEvents = False
Worksheets("GSCells").Cells(5, 4).Value = 22
Worksheets("GSCells").Cells(5, 5).GoalSeek Goal:=0, ChangingCell:=Worksheets("GSCells").Cells(5, 4)
var1 = Worksheets("GSCells").Cells(5, 4).Value
Worksheets("GSCells").Cells(10, 5).Value = var1
If var1 < 23 Then
Worksheets("Best").Cells(24, 11).Value = 23
End If
If var1 > 45 Then
Worksheets("Best").Cells(24, 11).Value = 45
End If
If var1 >= 23 And var1 <= 45 Then
Worksheets("Best").Cells(24, 11).Value = var1
End If
Application.EnableEvents = True
End Sub
` I made this code based on info of this forum. I have this code in 'ThisWorkbook' in Excel VBA. Initially, The Sub was named Workbook_SheetChange() but it returned an error ("Procedure declaration does not match description of event or procedure having same name").
This error disapeared after I changed its name to SC(). Dispite that, every time I change any value on any sheet, it just doesn't run.
However, if I go into VBA and press F5, it works fine.
Can someone help?
Many thanks in advance.