It gets thicker...
I want to learn the methods of rylo, but as I quickly understood yours, Greg M, I did the following...
Private Sub Worksheet_Activate()
Dim PeriodArray() As String
dog = Worksheets("COS - Monthly").Range("Q_Period").Columns.Count
ReDim PeriodArray(dog, 2)
Count = 1
DeCount = 1
For Count = 0 To dog - 1
PeriodArray(Count, 1) = Worksheets _
("COS - Monthly").Range("Mon_MC_1b").Offset(-1, 6 + Count)
PeriodArray(Count, 2) = Worksheets _
("COS - Monthly").Range("Mon_MC_1b"). _
Offset(-1, 6 + Count).Column
Next Count
' To check my work
' For DeCount = 0 To dog - 1
' Debug.Print PeriodArray(DeCount, 1)
' Debug.Print PeriodArray(DeCount, 2)
' Next DeCount
ActiveSheet.cbQPeriod.List = PeriodArray()
'
End Sub
Instead of a listbox I chose a combobox because it gave me a single choice in the box in it's "unactivated" state, and when the arrow was clicked it gave me a drop-down selection. I was unable to do that with the list box. Also something I can't understand is that I tell the cb (as was the case in the lb) there are two columns, I must bind column 1, but the month data appears to be in the second column for if I set that one to a 0 width ("31.95 pts; 0 pts" instead of "0 pts; 31.95 pts"), no more month. I am probably struggling with learning the concept of a two-dimensional array, I suspect, and the model I have in my head just ain't quite right.
Anyway, those are the curiosities to me. The real question is now that someone selects a month in the display, how do I determine at what position in the 2-D array it is at so I can extract the column?
I can always revert to doing a .Find in the range, but this is as much of a learning exercise to understand arrays better. Then I get to tackle some of the "rylo concepts"...
btw, the offsets, as you probably quickly figure out, are simply to provide the proper offset to read in the horizontal data.
I have been toying with the change event of the cb, but am having a difficult time locating anything that returns my place in the array. And I have an awful feeling in my head that both of you are laughing at how complicated I may have made this for myself, but hey, btdt (been there, done that) ...
As always, great appreciation.
-Bruce
Bookmarks