Solved

ComboBox

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now