AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile
Hi, I'm a bit new to VB and I'm having trouble importing a CSV into a workbook. Actually importing a known CSV is relatively easy but the CSV that I wish to import changes names each time (date-stamped). So what I'd like to to get VB to bring up the Open File window, that I may be able to select the appropriate file at the appropriate location. I've tried with this line of code below but it will not actually open the file after clicking the open button. varFile = Application.GetOpenFilename Can anyone help? Any help is appreciated. The rest of my code below.....but the macro already specifies which filename, I would like the user to specify the CSV file Sub CSV_Import() ' ' CSV_Import Macro ' ' Sheets("Bucket Totals").Select Cells.Select Selection.Clear Range("A1").Select Workbooks.Open FileName:="DrojexVBAAFS2_CUSTODY_BALANCES_01072003.CSV" Cells.Select Selection.Copy ActiveWindow.Close ActiveSheet.Paste Cells.Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .ShrinkToFit = False .MergeCells = False End With Cells.EntireColumn.AutoFit Rows("1:5").Select Range("A5").Activate Selection.Delete Shift:=xlUp End Sub Regards
Try using the "common dialogue control" in vb. Post back if you're stuck using. Cheers Steve [Edited by steve_w on 03-07-2003 at 11:07 AM GMT]