How to write a VBA subroutine one of whose arguments specifies WHICH PROPERTY to use in a loop
I'm writing a medium-complex set of Excel reports that requires sorting various collections. In each case I want to sort a collection based on a different property, but the logic is the same aside from that. So it's time to think about a subroutine that'll do the job.
But is it possible? For instance, in one case I want to sort a collection of User objects based on the LFName property; in another I'm sorting a collection of Xct objects on the Name property. I know a third such case is coming up where I want to sort a collection of objects based on a different property yet again.
So I want to write a subroutine that sorts the specified collection on the specified property. I'm not asking about how to do the sort; I'm already doing that. But is it possible for the caller to specify a different property (not a particular value) in each call? I've a notion I've seen something like that, long ago, but at the time I no doubt shrugged and thought it was too exotic for me to expect to need.
|