Solved

Excel VBA combobox update problem

Posted on 2002-03-14
10
2,550 Views
Last Modified: 2009-03-19
have a form with a combobox list box that gets updated with the program. It's not...

The named range is updating properly, but the form won't... here's my bits of code:

Worksheets("1stontape").Names.Add Name:="firstlist", RefersToR1C1:="=R1C1:R" & maxrowlist + 1 & "C1"

thats for updating the name range..

the rowsource IS set to firstlist. If I manually check the range, it IS working... but my form usually don't display it.... if I play around w/it enough, I might get lucky, but...

thanks!
0
Comment
Question by:starl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6867580
please note that there is an MSOffice Topic area, where  you should get more experts for that problem:
http://www.experts-exchange.com/jsp/qList.jsp?ta=msoffice

Now, how/when do you update your forms' combobox?

CHeers



0
 
LVL 8

Author Comment

by:starl
ID: 6868050
I know angel... but this is a VBA prob and there's no real section for VBA. Though there is some knowledge of VBA in Office I hoped to get more here.

... update the combobox... well, it reads the listing off a named range on a sheet.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6868732
Hi starl, you provided the update of the named range, but is the form loaded and updated also?

i mean is there also a load list procedure to get the values in the combobox? or is that done at design time

:O)Bruintje
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:starl
ID: 6869021
*sigh* my ignorance and delving into something I don't knwo 100% is showing...

I've created a form in the editor. There is code behind that form. The part I'm having problems with is a combobox. It gets its list from a "rowsource" which, in this case, is a dynamic named range. I have other comboboxes on the form, but they are static - they show the info no problem.

Even if I restart the program and there IS info in the range, the combobox will not necessarily reflect this.

shouldn't it at least work ALL THE TIME if I restart the program? I've either done something wrong or there's a bug/error somewhere.

btw, excel 2000
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6869637
Hi starl, ok i did this

-put a form in the editor
-a combox on it
-then used this code to fill the box

Private Sub UserForm_Initialize()
Dim i As Integer
  For i = 0 To 10
    ComboBox1.AddItem i * i, i
  Next i
End Sub

-instead of the values i used with i you can loop through the named range to fill the box

if you need any help on that just ask....

HTH:O)Bruintje
0
 
LVL 8

Author Comment

by:starl
ID: 6869656
ok.. the named range is "firstlist" and the size will vary with time... how to work with it??
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6869724
:O) i had already pulled the plug on excel

Private Sub UserForm_Initialize()
Dim i As Integer
  For i = 0 To Worksheets(1).Range("firstlist").Count - 1
    ComboBox1.AddItem Range("firstlist").Value(i + 1, 1), i
  Next i
End Sub

HTH:O)Bruintje
0
 
LVL 12

Accepted Solution

by:
roverm earned 100 total points
ID: 6869829
You are using the worksheet name where you should have used the workbook names list...:

ActiveWorkbook.Names.Add Name:="firstlist", RefersToR1C1:="='1stontape'R1C1:R" & maxrowlist + 1 & "C1"

Also:
(But I don't know if you already did that): Refresh the combo by using:

Combo.RowSource = "firstlist"

You must do this at Form activation.

D'Mzzl!
RoverM
0
 
LVL 8

Author Comment

by:starl
ID: 6870113
Ha! thanks rover - that fixed it.. I did wonder why the namedrange had that extra line in the excel list of definitions. THANK YOU!

and I WAS missing the refresh. the last piece of the puzzle - thank you.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6870571
Thanks starl! Glad I could help!

D'Mzzl!
RoverM
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question