Solved

ComboBox

Posted on 2002-06-04
5
343 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
[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
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

624 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