tsunamisurfer
IS-IT--Management
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:="D:\Projex\VBA\AFS2_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
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"
Cells.Select
Selection.Clear
Range("A1"
Workbooks.Open FileName:="D:\Projex\VBA\AFS2_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"
Range("A5"
Selection.Delete Shift:=xlUp
End Sub
Regards