Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA combobox update problem

Posted on 2002-03-14
10
Medium Priority
?
2,581 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 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