View Single Post
 
Old 02-09-2016, 05:00 PM
OldColdDreamer OldColdDreamer is offline Windows 10 Office 2013
Novice
 
Join Date: Feb 2016
Location: Stockport UK
Posts: 3
OldColdDreamer is on a distinguished road
Default

Thanks, Debaser. I think I am starting to get sorted out with my array and const declarations. Two quick follow-ons from this, though:

I want to call a sub (or a function?) when I try to leave a worksheet, which does some analysis of the data on that sheet, and leaves the results in various arrays.

What seems to work is the following coding...

In worksheet "Income" (aka "Sheet2"):
Private Sub worksheet_deactivate()
Call ThisWorkbook.Income_Deactivate
End Sub

In ThisWorkbook:
<various array and constant declarations (I'm happy with these now)>
Public Sub Income_Deactivate()
<sort the data into the arrays, maybe generate error messages>
End Sub

I seem to need the double-layer call in order to get my "deactivate()" code invoked when (say) the user clicks on the tab for another worksheet, and then do the processing where the arrays etc. are in scope. But is there a better way of achieving this?
In the event that my analysis finds an error, can I (maybe by using functions instead of subs) force the user to stay on the outgoing worksheet and fix the error?
Reply With Quote