PC Review


Reply
Thread Tools Rate Thread

Append Excel Data from a named Range to an Exceldatabase

 
 
Janetzky@googlemail.com
Guest
Posts: n/a
 
      15th Aug 2007
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!

 
Reply With Quote
 
 
 
 
Excel_Expert
Guest
Posts: n/a
 
      15th Aug 2007
On Aug 15, 7:30 am, "Janet...@googlemail.com"
<Janet...@googlemail.com> 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

 
Reply With Quote
 
Janetzky@googlemail.com
Guest
Posts: n/a
 
      16th Aug 2007
Thanks for the post.

The code is not working even after modification. The missing part,
however, is the appending of the data in the "database" file after the
last line of existing data.How can i count the rows of data? After
that i assume that i will use the second coordinate of the offset
formula to trigger the row for the paste.
Please help again.

Sven

Excel_Expert wrote:
> On Aug 15, 7:30 am, "Janet...@googlemail.com"
> <Janet...@googlemail.com> 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


 
Reply With Quote
 
Excel_Expert
Guest
Posts: n/a
 
      16th Aug 2007
Hi

Can you tell me what line doesn't seem to be working? Is there an
error you face?

Oh... I now see the error. I think I didn't write this line of code
rngCopy.Copy

Just re-copy the code and try running it.

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

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


rngCopy.Copy

'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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to print a named range of data excel Rachel Microsoft Excel Programming 1 18th Feb 2009 10:11 AM
OutLook Form importing Data from Excel Named range LenJr Microsoft Outlook Form Programming 0 23rd Jul 2008 04:06 PM
Named Range DTS Import of Excel Data =?Utf-8?B?SGFyb2xkIEk=?= Microsoft Excel Misc 0 28th Sep 2007 05:38 PM
sending data to excel to a named range Scott Microsoft Excel Discussion 2 28th Nov 2003 11:37 PM
sending data to a named range in excel Scott Microsoft Access External Data 3 28th Nov 2003 08:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:53 PM.