View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Excel_Expert Excel_Expert is offline
external usenet poster
 
Posts: 4
Default Append Excel Data from a named Range to an Exceldatabase

On Aug 15, 7:30 am, "
wrote:
I wish to add a code to a workbook in order to append information of a
named range "data" to an external Excelfile, the path to file is in a
cell of the same workbook named "location". The sheet in the external
file is called "database". The data of the named range (7 columns x
7rows) is structured exactly as in the "database".The twist is it
needs to append the data below existing data in that file. I figure
there need to be some sort of a loop which counts the last row and
data needs to be copied beneath that data in the closed file.
Maybe some one can help me out there. Thanks in advance, Sven!


Sub CopyDataRange()
Dim rngCopy as Range
Dim wbDest as Workbook

set rngCopy = Range("Data")
set wbDest = Workbooks.Open(Range("location")

'Assuming Data on Database Sheet starts from Column A
wbDest.Sheets("Database").Range("A65536").offset(1 ,0).PasteSpecial
xlPasteAll
Application.CutCopyMode = False
wbDest.Save

msgbox "Completed"
End Sub