I have a monthly report to compile with 1000's of lines of data on multiple spreadsheets.
I have figured out how to import data from a Excel Workbook to another Excel Workbook as per the code below
Sub exa()
Dim wbSource As Workbook
Dim strFileName As String
strFileName = Application.GetOpenFilename(FileFilter:="Excel Workbooks (*.xls), *.xls", _
Title:="Select Source File:")
'// Bail if not file selected. //
If strFileName = "False" Then Exit Sub
Set wbSource = Workbooks.Open(strFileName, , True)
With wbSource.Worksheets("Sheet1")
.Range("A:P").Copy ThisWorkbook.Worksheets("Sheet1").Range("A:P")
.Parent.Close False
End With
End Sub
What I would like to do is understand how to change this above macro so that I can import from a CSV file instead of a normal Workbook file (the program that prints my data saves in a .csv format.
Also, if anyone can help.. further more to the above request for assistance, for one report I have 15 different CSV files. I would to be able to highlight all 15 CSV files when the 'select file' box opens & have each of these CSV files copy to a different sheet on one workbook. Such as the following
CSV1 file
CSV2 file
CSV3 file etc etc
Each of these copy onto their own worksheet (report.xls)
Sheet 1 would then hold CSV1 file's data
Sheet 2 would then hold CSV2 file's data
Sheet 3 would then hold CSV3 file's data
and so on..
I am new to macro's so this may be simple but I have spent hours just to get this first part right.
Bookmarks