G
Guest
Dear All,
Apparently, RowSource is not supported in Office for Mac, which is causing me a great deal of pain. The problem is this:
I have a userform with a ListBox that retreives data from a named range. In the Windows version of Excel, I can just set the ListBox to get data using RowSource (e.g. ListBox.RowSource = "NamedRange"). However, on the Mac, I have to do some meatball surgery (using arrays and a FOR loop) to populate the list. My current code for this task is not very efficient as shown below.
Dim ListArray(2000, 2) As String
With Worksheets("Data")
ListBox.ColumnCount = 2
For i = 0 To .Range("NamedRange").Rows.Count
ListArray(i, 0) = .Range("NamedRange").Cells(i + 1, 1)
ListArray(i, 1) = .Range("NamedRange").Cells(i + 1, 2)
Next
End With
ListBox.List() = ListArray
For a list that contains around 2000 rows, the load time for the userform is (somewhat) significant. Well, maybe it's not that significant (a slight lag), but it's annoying the hell out of me. With RowSource, the form loads almost instantly.
My question is, "is there an equivalent alternative to RowSource for the Mac version of Office?" Or, is there a more efficient way to load data into a ListBox other than arrays and loops?
Any help is much appreciated.
Regards,
Albert
Apparently, RowSource is not supported in Office for Mac, which is causing me a great deal of pain. The problem is this:
I have a userform with a ListBox that retreives data from a named range. In the Windows version of Excel, I can just set the ListBox to get data using RowSource (e.g. ListBox.RowSource = "NamedRange"). However, on the Mac, I have to do some meatball surgery (using arrays and a FOR loop) to populate the list. My current code for this task is not very efficient as shown below.
Dim ListArray(2000, 2) As String
With Worksheets("Data")
ListBox.ColumnCount = 2
For i = 0 To .Range("NamedRange").Rows.Count
ListArray(i, 0) = .Range("NamedRange").Cells(i + 1, 1)
ListArray(i, 1) = .Range("NamedRange").Cells(i + 1, 2)
Next
End With
ListBox.List() = ListArray
For a list that contains around 2000 rows, the load time for the userform is (somewhat) significant. Well, maybe it's not that significant (a slight lag), but it's annoying the hell out of me. With RowSource, the form loads almost instantly.
My question is, "is there an equivalent alternative to RowSource for the Mac version of Office?" Or, is there a more efficient way to load data into a ListBox other than arrays and loops?
Any help is much appreciated.
Regards,
Albert