Hello everybody,
I am a PhD Student at the University of Freiburg in Germany.I manage csv data and I would like to import such data in excel and organize them in a worksheet. I have already written something in VBA but not really want I wanna do. I am searching for everyone who want help me or collaborate to broad the macro to other simple arithmetic functions. I could insert the name in the scentific pubblication if somebody want to take part to this simple macro. If you are interested please contact me at alberto.steffani@ocbc.uni-freburg.de.
What I would like to do is this:
I have 100 *.csv files, each on contains 2 columns. The first columns is the same for each file and the second changes and I am interested to have such columns in the same Worksheet. What it follows is simple the sum of each columns extracted and later a linear extrapolation of the data. What I done until no is that:
Option 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
ActiveWorkbook.Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Workbooks(Mid(oeffnen, InStrRev(oeffnen, "\") + 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
This program permits to choose the *.csv files in one shot and it place each set of 2 columns in different columns than the second extract the second columns of each set and place all of them in one single new worksheet. The problem is that it places each column in the same columns and I wanna have just the opposite: each column in different columns.
I hope that somebody will help me. I thank you in advance.
Sincerely,
Alberto Steffani
I am a PhD Student at the University of Freiburg in Germany.I manage csv data and I would like to import such data in excel and organize them in a worksheet. I have already written something in VBA but not really want I wanna do. I am searching for everyone who want help me or collaborate to broad the macro to other simple arithmetic functions. I could insert the name in the scentific pubblication if somebody want to take part to this simple macro. If you are interested please contact me at alberto.steffani@ocbc.uni-freburg.de.
What I would like to do is this:
I have 100 *.csv files, each on contains 2 columns. The first columns is the same for each file and the second changes and I am interested to have such columns in the same Worksheet. What it follows is simple the sum of each columns extracted and later a linear extrapolation of the data. What I done until no is that:
Option 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
ActiveWorkbook.Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Workbooks(Mid(oeffnen, InStrRev(oeffnen, "\") + 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
This program permits to choose the *.csv files in one shot and it place each set of 2 columns in different columns than the second extract the second columns of each set and place all of them in one single new worksheet. The problem is that it places each column in the same columns and I wanna have just the opposite: each column in different columns.
I hope that somebody will help me. I thank you in advance.
Sincerely,
Alberto Steffani