It's very convenient to set up Worksheet aliases before any code runs. So I made some public variables:
and in the Worksheet_Open event (which I define in "ThisWorkbook"), I set them to the respective worksheets:Code:Public outsht As Worksheet Public loansht As Worksheet Public batsht As Worksheet
However, when I run this function (which is called from a toolbar that I create):Code:Private Sub Workbook_Open() Set outsht = Worksheets("pool-level analysis") Set loansht = Worksheets("loan-level analysis") Set batsht = Worksheets("batch files") Call createToolBar End Sub
I get an error "variable not found" for outsht.Code:Sub runApproximator() ' Sheets("pool-level analysis").Range("$AW$4") = "Approximator" ' Run Type outsht.Range("$AW$4") = "Approximator" ' Run Type End Sub
Why is this? Are complex objects like Worksheets not allowed to be public?


Reply With Quote
