I have a Subroutine “Days” which has a variable Days. I want to pass values form that Days variable to a different subroutine “GetDays”
For eg:
Sub Day()
Dim Days() as variant
Days = Array(1,3,5,7,10,11)
End Sub
Sub GetDay()
‘How do I get the values of Days here?
End Sub
Not completely sure I understand what you’re after, but my best guess is that you want to set up a “DayClass” object that both holds the days values and returns them to other functions when they’re needed:
(1) in the VBA editor, insert a CLASS module
(2) in the properties window for this module, change the name to (say) DayClass (overriding the default name “Class1”.)
(3) put this code into the DayClass module:
(4) To see the code above in action, insert a regular MODULE and put this little function in it, which may be invoked from the formula bar (if you want):
(5) Since “GetDays” is a public function in a regular code module, you can test this out by entering the following formula into any spreadsheet cell: