Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default additem performance

I have a combobox that is being populated from the contents of a
different worksheet in the same workbook. The problem is that it is
taking over 10 seconds to run - it only runs once during the
workbook_open event.

Here is the code:
================================================== ========
Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As Integer
Dim ws As Worksheet
Dim wb As Workbook

Set wb = Workbooks(1)

Set ws = wb.Sheets("GeoTier")

For i = 2 To 24183
GeoCombo.AddItem ws.Cells(i, 3)
Next i

End Sub
================================================== =============

In a future release I will get the data from a local MS Access
database. How can I speed up the current loading of this combobox?

TIA
mark
markm-at-visionsw.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default additem performance

Try getting the data into a variant first

Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As long
Dim vArr as variant


vArr= Workbooks(1).Sheets("GeoTier").range("C2:C24183")

For i = 2 To 24183
GeoCombo.AddItem vArr(i-1,1)
Next i

End Sub


--
Charles
______________________
Decision Models
FastExcel 2.1 now available
www.DecisionModels.com

================================================== =============
"Mark" wrote in message
om...
I have a combobox that is being populated from the contents of a
different worksheet in the same workbook. The problem is that it is
taking over 10 seconds to run - it only runs once during the
workbook_open event.

Here is the code:
================================================== ========
Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As Integer
Dim ws As Worksheet
Dim wb As Workbook

Set wb = Workbooks(1)

Set ws = wb.Sheets("GeoTier")

For i = 2 To 24183
GeoCombo.AddItem ws.Cells(i, 3)
Next i

End Sub
================================================== =============

In a future release I will get the data from a local MS Access
database. How can I speed up the current loading of this combobox?

TIA
mark
markm-at-visionsw.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default additem performance

Another possibility is to just assign it in one step:

Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As long
Dim vArr as variant

GeoCombo.List = Workbooks(1).Sheets("GeoTier") _
.range("C2:C24183").Value

End Sub

--
Regards,
Tom Ogilvy


"Charles Williams" wrote in message
...
Try getting the data into a variant first

Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As long
Dim vArr as variant


vArr= Workbooks(1).Sheets("GeoTier").range("C2:C24183")

For i = 2 To 24183
GeoCombo.AddItem vArr(i-1,1)
Next i

End Sub


--
Charles
______________________
Decision Models
FastExcel 2.1 now available
www.DecisionModels.com

================================================== =============
"Mark" wrote in message
om...
I have a combobox that is being populated from the contents of a
different worksheet in the same workbook. The problem is that it is
taking over 10 seconds to run - it only runs once during the
workbook_open event.

Here is the code:
================================================== ========
Private Sub GeoComboBoxInit(GeoCombo As ComboBox)

Dim i As Integer
Dim ws As Worksheet
Dim wb As Workbook

Set wb = Workbooks(1)

Set ws = wb.Sheets("GeoTier")

For i = 2 To 24183
GeoCombo.AddItem ws.Cells(i, 3)
Next i

End Sub
================================================== =============

In a future release I will get the data from a local MS Access
database. How can I speed up the current loading of this combobox?

TIA
mark
markm-at-visionsw.com





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with: ListBox1.AddItem (ws.Name) Ron de Bruin Excel Worksheet Functions 0 May 18th 05 07:02 PM
AddItem Method Todd Huttenstine Excel Programming 3 April 21st 04 03:53 PM
Please help with AddItem method Shilps Excel Programming 2 April 19th 04 01:24 PM
.additem Robert Couchman[_4_] Excel Programming 3 February 20th 04 02:47 PM
additem listbox CG Rosén Excel Programming 2 December 14th 03 08:58 PM


All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"