Hi all,

I have the following code, where i mainly copy cells values to other cells and erase values from cells as an event is triggered. If i try to add a line where i try to run a WAV file I run out of stack space. Should I declare some variables at the beginning so to free some memory??
They are single cells mostly numbers with a couple of decimals, and with time format a couple of time.

Many thanks
BC


Private Sub Worksheet_Calculate()

If Range("P15") <> "" Then
If Range("l15").Text = "off" Then Exit Sub
If Range("l18").Text = "ERROR" Then Exit Sub
ActiveSheet.Unprotect
Range("P16") = Range("P15")
If Range("Q17").Text = "yes" Then
Range("j28") = Time
Range("F36").Rows.EntireRow.Insert
Range("O19") = Range("P16")
Range("y14") = Range("o19")
Range("P19") = Range("J29")
Range("Q19") = Range("b9")
Range("n31") = Range("b9")
Range("N33") = Range("D10")
Range("O33") = Range("E10")
Range("q33") = Range("y28")
Range("F36") = Range("y14")
Range("E36") = Range("G10")
Range("G36") = Range("p19")
Range("P16") = ""

ActiveSheet.Protect

End If
End If

If Range("Q24").Text = "yes" Then
ActiveSheet.Unprotect
Range("H36") = Range("P22")
Range("k28") = Time
Range("I36") = Range("k29")
Range("I33") = Range("k29")
Range("K33") = Range("b9")
Range("J36") = Range("G10")

Range("O19") = ""
Range("P19") = ""
Range("Q19") = ""
Range("Y14") = ""
Range("q33") = ""

ActiveSheet.Protect

End If

If Range("t30") <> "" Then Exit Sub
If Range("s30") <> "" Then
ActiveSheet.Unprotect
Range("t30") = Time
ActiveSheet.Protect
End If

If Range("t31") <> "" Then Exit Sub
If Range("s31") <> "" Then
ActiveSheet.Unprotect
Range("t31") = Time
ActiveSheet.Protect
End If

If Range("t32") <> "" Then Exit Sub
If Range("s32") <> "" Then
ActiveSheet.Unprotect
Range("t32") = Time
ActiveSheet.Protect
End If

End Sub