?
Solved

Select option in a drop-down menu from excel file?

Posted on 2003-03-04
3
Medium Priority
?
211 Views
Last Modified: 2010-04-07
I'm making a database (if you can call it that) the saves the user input into an excel file but I'm trying to load it back into the form.  Does anyone know how to do this with a drop down menu?  I've gotten desperate and resorted to using radio buttons...  
I hope it's easy and I just don't get it.
0
Comment
Question by:lemonduck
3 Comments
 
LVL 11

Expert Comment

by:supunr
ID: 8068125
when you say save into an Excel file I belive you mean a simple text file with one line of code.  So use code something similar to that. (refer to the second function)

Private Sub SaveDataToExcel()
    Dim strExcelFile As String
    Dim ArrayList(10) As String ' temporary sample array to save
    Dim i As Long
   
    strExcelFile = "C:\data.xls"
   
    ' populate array with dummy data
    For i = 0 To 10
        ArrayList(i) = Str(i)
    Next i
   
   
    Open strExcelFile For Output As #1
    'now save the array
    For i = 0 To 10
        Write #1, ArrayList(i)
    Next i

    Close #1
End Sub

Private Sub LoadDataToCombo()
    On Error GoTo LoadErr
    Dim strExcelFile As String
    Dim strComboItem As String
    Dim i As Long
   
    strExcelFile = "C:\data.xls"
   
    Open strExcelFile For Input As #1
    'now save the array
    While (Not EOF(1))  ' lopp until the end of the file
        Input #1, strComboItem  ' get each line (combo item)
        If (Trim(strComboItem) <> "") Then  ' if there is data
            combo1.AddItem strComboItem
        End If
    Loop

    Close #1
    Exit Sub
   
LoadErr:
    MsgBox "Error loading Data to the list" & vbcrl & Err.Number & ": " & Err.Description
    On Error GoTo 0
End Sub

Hope this is useful.  Good Luck!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9046854
Hi lemonduck,
It appears that you have forgotten to close 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:

    Save as PAQ -- No Refund.

lemonduck, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9151041
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

616 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