Solved

ComboBox

Posted on 2002-06-04
5
322 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

839 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