Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi,
I've written the macro below to read in and append several csv files together in excel. It works but can anyone tell me how I alter it to read only the header row from the first file? Thanks Kirstin Sub List_All_The_Files_Within_Path() Dim File_Path As String Dim cell_to_paste_next_dataset As Range Dim active_workbook, dataset_workbook As Workbook Dim active_sheet As Worksheet Dim file_count As Integer Application.DisplayAlerts = False 'SPECIFY LOCATION of CSV FILES File_Path = "S:\Data" Set cell_to_paste_next_dataset = Cells(1, 1) Set active_workbook = ActiveWorkbook Set active_sheet = ActiveSheet With Application.FileSearch .NewSearch .LookIn = File_Path .Filename = "*.csv" 'CHANGE FILE EXTENSION TO OTHER EXCEL BASED EXTENSION IF YOU WANT .SearchSubFolders = False .Execute For file_count = 1 To .FoundFiles.Count If File_Path & "\" & active_workbook.Name < .FoundFiles(file_count) Then Workbooks.Open Filename:=.FoundFiles(file_count) Set dataset_workbook = ActiveWorkbook Range(ActiveCell.SpecialCells(xlLastCell), Cells(2)).Copy active_sheet.Activate Cells(ActiveCell.SpecialCells(xlLastCell).Row, 1).Select ActiveSheet.Paste dataset_workbook.Close End If Next file_count End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to access multiple Excel files | Excel Discussion (Misc queries) | |||
Macro: Filter Multiple header then extract to Multiple Files | Excel Discussion (Misc queries) | |||
Run multiple excel files off of one macro. | Excel Discussion (Misc queries) | |||
Run multiple excel files off of one macro. | Excel Worksheet Functions | |||
Excel read-only files | New Users to Excel |