Solved

ComboBox

Posted on 2002-06-04
5
329 Views
Last Modified: 2010-05-02
I know this is a simple task, but i am very weak with comboboxes on my userform, i can additems by inserting them into the code. but how do i add these items from an excel worksheet.  For example i need to add the data from a sheet labeled qcdata4 cell ag26,ag30,ag44,ag52. I know this has to be done in a userform intialize event but do not know the code. any help would be greatly appreciated.
0
Comment
Question by:stormhunter2000
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
killer5 earned 50 total points
ID: 7055504
*** I ASSUME YOU ONLY HAVE 4 ITEMS IN COMBOBOX ALL THE TIME
*** This may not be the exact solution but it will get you
*** started


Dim EApp As Excel.Application
Dim ESheet As Excel.Worksheet
Dim EBook As Excel.Workbook

Set EApp = CreateObject("Excel.Application")
EApp.Visible = False
EApp.Workbooks.Add
Set EBook = EApp.ActiveWorkbook
Set ESheet = EBook.Worksheets.ActiveSheet

Combo1.ListIndex = 0
ESheet.Range("AG26").Value = Combo1.Text
Combo1.ListIndex = 1
ESheet.Range("AG30").Value = Combo1.Text
Combo1.ListIndex = 2
ESheet.Range("AG44").Value = Combo1.Text
Combo1.ListIndex = 3
ESheet.Range("AG52").Value = Combo1.Text

EBook.SaveAs ("C:\Test.xls")
EApp.Application.Quit
Set EApp = Nothing
Set ESheet = Nothing
Set EBook = Nothing
0
 
LVL 1

Expert Comment

by:killer5
ID: 7055508
make sure you reference Excel Object.
1. click Project from menu
2. click References
3. Look for Excel Object Library (any version) then click OK
0
 
LVL 1

Expert Comment

by:killer5
ID: 7055546
there is an error in the code.. sorry.

just replace the
Set ESheet = EBook.WorkSheets.ActiveSheet
with
Set ESheet = EBook.ActiveSheet

thanks!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851489
Hi stormhunter2000,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept killer5's comment(s) as an answer.

stormhunter2000, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7912948
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

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!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

740 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