Importing a txt file to a ComboBox itens
Please, i need import the data txt file to a combobox list itens
How i do it -- Message posted from http://www.ExcelForum.com |
Importing a txt file to a ComboBox itens
Loop through the file and use additem to add to the combobox.
there are several ways to access the textfile Use File=Open to bring it in as a separate workbook in Excel 2000 and later, you can import it into an existing worksheet. You can use low level fileio to read the file. Post back in this thread with specific followup questions. -- Regards, Tom Ogilvy "mhferreira " wrote in message ... Please, i need import the data txt file to a combobox list itens How i do it? --- Message posted from http://www.ExcelForum.com/ |
Importing a txt file to a ComboBox itens
Try some code like the following:
Dim FName As String Dim FNum As String Dim S As String FName = "H:\test.txt" '<<<< CHANGE FILE NAME FNum = FreeFile Open FName For Input As #FNum Do Input #FNum, S Userform1.ComboBox1.AddItem S Loop Until EOF(FNum) Close #FNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mhferreira " wrote in message ... Please, i need import the data txt file to a combobox list itens How i do it? --- Message posted from http://www.ExcelForum.com/ |
Importing a txt file to a ComboBox itens
The following is better, as it will properly handle an empty
input file: Dim FName As String Dim FNum As String Dim S As String FName = "H:\test.txt" '<<< CHANGE FILE NAME FNum = FreeFile Open FName For Input As #FNum Do Until EOF(FNum) Input #FNum, S Me.ComboBox1.AddItem S Loop Close #FNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Chip Pearson" wrote in message ... Try some code like the following: Dim FName As String Dim FNum As String Dim S As String FName = "H:\test.txt" '<<<< CHANGE FILE NAME FNum = FreeFile Open FName For Input As #FNum Do Input #FNum, S Userform1.ComboBox1.AddItem S Loop Until EOF(FNum) Close #FNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mhferreira " wrote in message ... Please, i need import the data txt file to a combobox list itens How i do it? --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 09:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com