Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
importing 10 sets of data with a macro
The following is what I'm trying to do with a macro. This will work for the
same 10 sets of data, but I would to change this to work for data from different file names. Is there a way to be prompted with an input box to click on the data files that I want? The data is always in the same folder (so the path is always the same) and the last digit changes in every file. Thanks and any ideas/help would be much appreciated. Sub Import_10_Data_Sets() ' ' Import_10_Data_Sets Macro ' Macro recorded 7/19/2005 by Christopher M. Ripperda ' ' With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR11.CSV" _ , Destination:=Range("A1")) .Name = "717CR11" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("D1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR12.CSV" _ , Destination:=Range("D1")) .Name = "717CR12" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("G1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR13.CSV" _ , Destination:=Range("G1")) .Name = "717CR13" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("J1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR14.CSV" _ , Destination:=Range("J1")) .Name = "717CR14" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("M1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR15.CSV" _ , Destination:=Range("M1")) .Name = "717CR15" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("P1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR16.CSV" _ , Destination:=Range("P1")) .Name = "717CR16" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("S1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR17.CSV" _ , Destination:=Range("S1")) .Name = "717CR17" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("V1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR18.CSV" _ , Destination:=Range("V1")) .Name = "717CR18" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("Y1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR19.CSV" _ , Destination:=Range("Y1")) .Name = "717CR19" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("AB1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Chris Ripperda\My Documents\Chris's Documents\Summer Chem. Project\7-17-05 -- Lifetime Expt\Data\717CR20.CSV" _ , Destination:=Range("AB1")) .Name = "717CR20" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Range("D1").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel graph 3 sets of data. 2 sets as lines 1 as column? | Charts and Charting in Excel | |||
Macro and Drop down list to show different sets of data do not wor | Excel Discussion (Misc queries) | |||
Importing data via macro | New Users to Excel | |||
How can I use the same macro for different sets of data? | Excel Discussion (Misc queries) | |||
Creating a pivot table from different sets of data using a macro | Excel Programming |