I am having a problem with excel crashing when i run VBA code on an excel sheet. I have some code to add a formula to a range of cells as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("testpage").Range("A1:A8").Formula = "=B1+C1"
End Sub
When this code is run i get a message saying "excel has encountered a problem and needs to close" and excel closes.
IF i run the code in the worksheet_active()
class it works fine and doesn't crash
Private Sub Worksheet_Activate()
Worksheets("testpage").Range("A1:A8").Formula = "=B1+C1"
End Sub
But I really need it to work in the worksheet_change()
class.
Has anyone experienced similar crashes when using the worksheet_change()
class and can anyone point in the right direction to fix this issue ?