ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   merging two files (https://www.excelbanter.com/excel-programming/301510-merging-two-files.html)

morry[_20_]

merging two files
 
I have two files that have the same format and I am trying to merge them
into one spreadsheet. I have to import both files from a CSV format.
When I import both of them into the same sheet, now, I try two bring
them into (A1). I want them in the same columns but when i bring the
second file in it pushes the first file over to the right instead of
down. Is there a way to merge these sheets to the same columns.

Thank you for any suggestions

Morry


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

merging two files
 
in the command window (or use the shell command)

copy a.csv + b.csv c.csv


then import c.csv




otherwise do your import for the first at A1 and you inport for the second
at

cells(rows.count,1).end(xlup)(2)


--
Regards,
Tom Ogilvy

"morry " wrote in message
...
I have two files that have the same format and I am trying to merge them
into one spreadsheet. I have to import both files from a CSV format.
When I import both of them into the same sheet, now, I try two bring
them into (A1). I want them in the same columns but when i bring the
second file in it pushes the first file over to the right instead of
down. Is there a way to merge these sheets to the same columns.

Thank you for any suggestions

Morry


---
Message posted from http://www.ExcelForum.com/




morry[_22_]

merging two files
 
Thanks for the help Tom. But I have another question. I am using th
macro recorder to import the external data and macros usually give m
more code than I really need to perform the function. I am not exactl
sure how to insert the piece of code you gave me, into the macro code
When I created the macro I scrolled down to the end of the first fil
and inserted the second file. I listed the pertinent code segmen
below.
The code you gave me was: cells(rows.count,1).end(xlup)(2)
I tried a couple different ways to replace this with the range but i
wouldn't work. Could you please tell me how to use this code.

Thank you very much,

Morr

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

merging two files
 
I listed the pertinent code segment
below.

No you didn't. Can't do much without it.

--
Regards,
Tom Ogilvy

"morry " wrote in message
...
Thanks for the help Tom. But I have another question. I am using the
macro recorder to import the external data and macros usually give me
more code than I really need to perform the function. I am not exactly
sure how to insert the piece of code you gave me, into the macro code.
When I created the macro I scrolled down to the end of the first file
and inserted the second file. I listed the pertinent code segment
below.
The code you gave me was: cells(rows.count,1).end(xlup)(2)
I tried a couple different ways to replace this with the range but it
wouldn't work. Could you please tell me how to use this code.

Thank you very much,

Morry


---
Message posted from http://www.ExcelForum.com/




morry[_23_]

merging two files
 
I'm sorry Tom, I went and copied it but I forgot to paste it to thi
message. I listed it below this time.

Range("A2322").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\rg42735\Desktop\Monthl
Reports\Work in Progres
Report\MonthlyReportCSVs\CA\URLTemplateAction." _
, Destination:=Range("A2322"))
.Name = "URLTemplateAction._6"


Thank you,

Morr

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

merging two files
 
I would try:

Activesheet.End(xlup)(2).Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\rg42735\Desktop\Monthly
Reports\Work in Progress
Report\MonthlyReportCSVs\CA\URLTemplateAction." _
, Destination:=Selection)
Name = "URLTemplateAction._6"

--
Regards,
Tom Ogilvy

"morry " wrote in message
...
I'm sorry Tom, I went and copied it but I forgot to paste it to this
message. I listed it below this time.

Range("A2322").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\rg42735\Desktop\Monthly
Reports\Work in Progress
Report\MonthlyReportCSVs\CA\URLTemplateAction." _
, Destination:=Range("A2322"))
Name = "URLTemplateAction._6"


Thank you,

Morry


---
Message posted from http://www.ExcelForum.com/




morry[_26_]

merging two files
 
I tried this code but it gives me a Run time error 438. "Object doesn'
support this property or method. Do you know why this would be? I
there any other way to accomplish this task that you may know of?

Thank you for all your help

Morr

--
Message posted from http://www.ExcelForum.com


morry[_27_]

merging two files
 
Does anyone know how to alter this so I can import two files onto th
same sheet and same columns. I have been altering this code all da
and it only shifts the code to the right it's driving me crazy. I
anyone has any ideas please let me know.
Here is what I have.
-----------------------------------------------------------------------------------
Sub Macro4()

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\rg5\Desktop\Monthl
Reports\Work in Progres
Report\MonthlyReportCSVs\ECN\URLTemplateAction." _
, Destination:=Range("A1"))
.Name = "URLTemplateAction._5"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.Refresh BackgroundQuery:=False
End With
Rows("1:6").Select
Selection.Delete Shift:=xlUp
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Application.Rows.End(xlUp).Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\rg5\Desktop\Monthl
Reports\Work in Progres
Report\MonthlyReportCSVs\CA\URLTemplateAction." _
, Destination:=Selection)
.Name = "URLTemplateAction._6"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.Refresh BackgroundQuery:=False
End With
End Sub
------------------------------------------------------------------------------------
Thank you

Morry :confused

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com