LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding values to a combo box

Good morning, everyone! I'm still learning the in's and out's of Excel
while I work on various projects. Right now, I'm trying to implement a
combo box onto a spreadsheet which will populate based on values
entered on another worksheet within the workbook. There a few factors
complicating my attempts though:

First, the combo box is on Sheet1 and the array is on Sheet2. I've
only had success in my efforts when I put the coding to populate the
combo box with the array information on the "ThisWorkbook" object in
VBA. Here is the code that works under this condition:

Sub Main()

Dim i As Integer
Dim NumCUSIPs As Integer
Dim CUSIPList() As String

' Calls the CUSIPManager function to populate
' the combo box
Call CUSIPManager(NumCUSIPs, CUSIPList())
For i = 1 To NumCUSIPs
Sheets("Sheet1").ComboBox1.AddItem CUSIPList(i)
Next i
Sheets("Sheet1").Select

End Sub

Sub CUSIPManager(CUSIPCount As Integer, CUSIPs() As String)

' Counts the number of CUSIPs related
' to the account and stores them to an array

Sheets("Sheet2").Select
Range("A2").Select
Do While ActiveCell.Value < ""
CUSIPCount = CUSIPCount + 1
ReDim Preserve CUSIPs(CUSIPCount)
CUSIPs(CUSIPCount) = ActiveCell.Value
ActiveCell.Offset(1).Select
Loop

End Sub

My second problem is that the array of information that will be used to
populate the combo box is of variable size. People could add or remove
information from the array at anytime. Right now, with the coding on
the "ThisWorkbook" object, it works fine. If my code is fine where it
is, then that eliminates problems 1 and 2 and brings me to problem 3...

Problem 3 is that when I first open the workbook, only the first value
in the array is populated. Is there anyway to have the values in the
combo box updated upon opening the worksheet?

I appreciate any insight that anyone can provide. I've been reading
these forums for a few months now for pointers as I've been learning
VBA, but this is the first time that I can officially say "I'm
stumped!". Thanks!

 
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
combo function of adding % jenn Excel Worksheet Functions 2 November 3rd 09 11:44 PM
Adding Items To a combo Box LoveCandle[_28_] Excel Programming 4 April 7th 06 09:58 PM
Combo box values based on other combo box value JCanyoneer Excel Programming 1 April 5th 05 06:41 PM
adding info to combo box JT[_2_] Excel Programming 0 February 17th 05 11:04 PM
registering the cell values of excel combo box associated values john_stevens Excel Programming 1 May 21st 04 09:39 PM


All times are GMT +1. The time now is 09:28 AM.

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

About Us

"It's about Microsoft Excel"