here's my current code:
Private Sub Workbook_Open()
sumn1 = Sheets("Main").Cells(1, 1).Value
sumn2 = Sheets("Main").Cells(2, 1).Value
sumn3 = Sheets("Main").Cells(3, 1).Value
sumn4 = Sheets("Main").Cells(1, 2).Value
sumn5 = Sheets("Main").Cells(2, 2).Value
sumn6 = Sheets("Main").Cells(3, 2).Value
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Main").Cells(1, 1) = sumn1
Sheets("Main").Cells(2, 1) = sumn2
Sheets("Main").Cells(3, 1) = sumn3
Sheets("Main").Cells(1, 2) = sumn4
Sheets("Main").Cells(2, 2) = sumn5
Sheets("Main").Cells(3, 2) = sumn6
End Sub
So, while the workbook is open and it's being worked in, after some actions the variables sumn1, sumn2..etc. (which are global variables) are getting added values, like +10 to sumn1, or +5 to sumn2 and so on. Since I want them saved after closing the workbook, I save them in a cell that I have hidden with ";;;".
The problem is, sometimes it works correctly, but sometimes (usually after longer time since workbook has been closed since) the variables reset to 0.
So first of, is my approach an alright one on how I am saving the data or its just not working because this approach is bad? If it's an alright approach then I guess I should search for my mistake somewhere else then.