Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Joao Silva   on Mar 26 In MS Office Category.

  
Question Answered By: Dylan Evans   on Mar 26

I am pressed for time and cannot give you a complete, tested
solution. Here are some pieces you might need.

You can find the code needed to create a new workbook on line (with
a Google search) or by recording a macro to do that. It would look
something like this.

Sub CreateWorkbook(Filename As String)
Dim wbNew As New Workbook
Set wbNew = Workbooks.Add
wbNew.SaveAs Filename:=Filename
Set wbNew = Nothing
End Sub

Sub PasteData(Source1 As Worksheet, Source2 As Worksheet, wsDestination As
Worksheet)

Dim sNextOpenCell As String
sNextOpenCell = "A" & Source1.UsedRange.Rows.Count + 1

' Copy all the data from source 1
Source1.UsedRange.Copy Destination:=wsDestination.Range("A1")

' Copy only the data body from source 2
BodyRows(Source2.UsedRange.Cells).Copy
Destination:=wsDestination.Range(sNextOpenCell)

End Sub
Function BodyRows(rData As Range) As Range

' The body of data (column headings stripped)
Set BodyRows = rData.Range("2:" & rData.Rows.Count)

End Function

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Copy two excel files into third with one header Or get search suggestion and latest updates.


Tagged: