LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Populate Combo Box with Values from CSV File

Glad it worked for you.

ps. You should stop watching the Sopranos <vbg!

Mark wrote:

Dave you are an "expletive deleted" genious! Thank you!! :)

"Dave Peterson" wrote:

Untested:

Option Explicit
Sub testme()

Dim WorkingFileName As String
Dim WorkingLocation As String
Dim WorkingDir As String
Dim CSVWks As Worksheet
Dim LastRow As Long
Dim myArray As Variant

WorkingDir = "c:\somestring\"

WorkingFileName = "master.csv"
WorkingLocation = WorkingDir & WorkingFileName

If IsFileOpen(WorkingLocation) = True Then
MsgBox "The file is in use, wait a moment and try again."
Exit Sub
Else
Set CSVWks = Workbooks.Open(Filename:=WorkingLocation).Workshee ts(1)
With CSVWks
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
myArray = .Range("A1:A" & LastRow).Value
.Parent.Close savechanges:=False
End With

Getesc.EscDrop.List = myArray
Getesc.Show
End If
End Sub




Mark wrote:

I have a combo box that I want to use an array of values from the first
column of a CSV file.

Workingfilename = "master.csv"
workinglocation = workingdir & Workingfilename

If IsFileOpen(workinglocation) = True Then

MsgBox ("The file is in use, wait a moment and try again.")
Exit Sub

Else

Workbooks.Open (workinglocation)
On Error Resume Next
a = 1
cnt = 1

Do While Cells(a, 1) < ""
a = a + 1
cnt = cnt + 1
Loop


Dim myrange As Range

Dim myArray()
Erase myArray 'incase it's already full


myArray = Workbooks("Master.csv").Range(Cells(1, 1), Cells(cnt, 1)).Values

Workbooks("Master.csv").Close True

Getesc.EscDrop.List = myArray

Getesc.Show

End If
End Sub

Any idea why it keeps coming up blank??


--

Dave Peterson


--

Dave Peterson


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate text box or combo box with external files with links to file names retterjr Links and Linking in Excel 0 February 18th 12 03:47 AM
Populate one combo box based on the selection of another combo box Alex Excel Programming 8 April 19th 07 06:40 PM
Populate form combo with unique values Piers 2k Excel Programming 1 August 24th 06 09:02 AM
Populate combo box with unique values only sjayar Excel Discussion (Misc queries) 1 November 7th 05 07:29 AM
Populate Combo Box with Text file Steve C Excel Programming 2 October 14th 05 04:31 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"