Hell everybody, I need help to fix the problem. I hope that somebody could solve the small problem.
The first part import the columns of the selected *.csv files in different worksheet. The second part copy the columns of each worksheet in the same worksheet but in the SAME column. I would have only the 2nd column of each worksheet in different colmuns in the worksheet.
Thank you in advanceOption Explicit Sub importCSV() Dim oeffnen, n As Integer Application.ScreenUpdating = False oeffnen = Application _ .GetOpenFilename(fileFilter:="Text Files (*.csv), *.csv", MultiSelect:=True) If IsArray(oeffnen) = False Then GoTo ENDE For n = 1 To UBound(oeffnen) Workbooks.OpenText oeffnen(n) ActiveWorkbook.Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) Workbooks(Mid(oeffnen(n), InStrRev(oeffnen(n), "\") + 1)).Close False Next n ENDE: Application.ScreenUpdating = True Dim J As Integer On Error Resume Next Sheets(1).Select Worksheets.Add ' add a sheet in first place Sheets(1).Name = "Combined" ' copy headings Sheets(2).Activate Range("A1").EntireRow.Select Selection.Copy Destination:=Sheets(1).Range("A1") ' work through sheets For J = 2 To Sheets.Count ' from sheet 2 to last sheet Sheets(J).Activate ' make the sheet active Range("A1").Select Selection.CurrentRegion.Select ' select all cells in this sheets ' copy cells selected in the new sheet on last line Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2) Next End Sub
Alberto Steffani
This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.
Thread Closed.
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
VBA for smarties - snb
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks