csv file importing and organizing

albertino

New Member
Joined
Feb 11, 2011
Messages
5
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(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

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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top