the files are originaly .txt files which are imported into the sheet with the application.GetOpenFileName.
this file contains callibration data for a certain machine it looks like this
01/03/11 1,95 1,99 1,98 2,02 2,00 2,00 2,00 1,98 1,96 1,96
the user is allowed to select multiple files which are all imported in 1 excel sheet.
using the following code
Dim Dest As Range
ChDrive "C"
ChDir "\documents and settings\user\desktop"
'after implementing change to correct Dir
FileCollection = Application.GetOpenFilename("DobFiles (*.DOB),*.dob", Title:="Open DOB Files only", MultiSelect:=True)
If IsArray(FileCollection) = False Then Exit Sub
For Each C In FileCollection
Set Dest = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
With .QueryTables.Add(Connection:="TEXT;" & C, Destination:=Dest)
.AdjustColumnWidth = False
.TextFileSpaceDelimiter = True
.TextFileTabDelimiter = True
.TextFileConsecutiveDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
Next C
End With
following that is a bunch of code to automaticly sort the data to date and format the area. then comes the code to replace the . with , which was mentioned earlier.
Range("A2:K2").Select
Range(Selection, Selection.End(xlDown)).Select
'this line is used because the amount of lines added may vary depending on the users demand
Selection.replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
the data is imported each on a different column, on the next sheet calculations are done on all the values in each column.
but when using the replace macro the values are not used in the graph or formula, but if i leave out the replacement from the macro and replace . with , using the CTRL+H command everything works fine
edit:
i copied the code from a different forum and seemed to do the job fine. but after inspecting i think it might have something to do with this line
With .QueryTables.Add(Connection:="TEXT;" & C, Destination:=Dest)
Bookmarks