PC Review


Reply
Thread Tools Rate Thread

Copy Range, Paste Value in New Workbook

 
 
BaggieDan
Guest
Posts: n/a
 
      15th Oct 2009
Hi All,

I am sure this is not as difficult as my man flu addled brain is making it.

I have a number of worksheets in a workbook that have the relevant
information I want to copy in the same range (A71:I71). I then have a
seperate workbook that I want to paste the values onto the next blank row, so
I can make a summary page.

The following code is what I have cobbled together from various posts (Kudos
to those who may recognise bits of their code! I know some of it came from
Ron db)

The source ranges will be present on all of the worksheets within the
workbook but will all have different names and the number of worksheets will
differ everytime this macro is run. The code seems to fall down as it only
copy & pastes from the first worksheet and then seems to ignore the rest!

The source worksheets are in a password protected workbook (that bit works
fine!)

Any help greatly appreciated.

Sub CopyDetails()

Dim wbk As Workbook
Dim sh As Worksheet
Dim Sourcewb As Workbook

Set wbk = Workbooks.Open(Filename:="filelocation", UpdateLinks:=True,
Password:="password")
Set Sourcewb = ThisWorkbook

For Each sh In Sourcewb.Worksheets
Range("A71:I71").Copy Destination:=Workbooks("Report").Worksheets("TM
Overview").Cells(Rows.Count, 1).End(xlUp)(2)
Next sh

End Sub

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      15th Oct 2009
Make sure you pick up the values in the correct sheet:

Sh.Range("A71:I71").Copy _
Destination:=Workbooks("Report").Worksheets("TM Overview") _
.Cells(Rows.Count, 1).End(xlUp)(2)

Those unqualified ranges will point at the active sheet.



BaggieDan wrote:
>
> Hi All,
>
> I am sure this is not as difficult as my man flu addled brain is making it.
>
> I have a number of worksheets in a workbook that have the relevant
> information I want to copy in the same range (A71:I71). I then have a
> seperate workbook that I want to paste the values onto the next blank row, so
> I can make a summary page.
>
> The following code is what I have cobbled together from various posts (Kudos
> to those who may recognise bits of their code! I know some of it came from
> Ron db)
>
> The source ranges will be present on all of the worksheets within the
> workbook but will all have different names and the number of worksheets will
> differ everytime this macro is run. The code seems to fall down as it only
> copy & pastes from the first worksheet and then seems to ignore the rest!
>
> The source worksheets are in a password protected workbook (that bit works
> fine!)
>
> Any help greatly appreciated.
>
> Sub CopyDetails()
>
> Dim wbk As Workbook
> Dim sh As Worksheet
> Dim Sourcewb As Workbook
>
> Set wbk = Workbooks.Open(Filename:="filelocation", UpdateLinks:=True,
> Password:="password")
> Set Sourcewb = ThisWorkbook
>
> For Each sh In Sourcewb.Worksheets
> Range("A71:I71").Copy Destination:=Workbooks("Report").Worksheets("TM
> Overview").Cells(Rows.Count, 1).End(xlUp)(2)
> Next sh
>
> End Sub


--

Dave Peterson
 
Reply With Quote
 
BaggieDan
Guest
Posts: n/a
 
      21st Oct 2009
Thank you sir,

2 little letters sorted it!

"Dave Peterson" wrote:

> Make sure you pick up the values in the correct sheet:
>
> Sh.Range("A71:I71").Copy _
> Destination:=Workbooks("Report").Worksheets("TM Overview") _
> .Cells(Rows.Count, 1).End(xlUp)(2)
>
> Those unqualified ranges will point at the active sheet.
>
>
>
> BaggieDan wrote:
> >
> > Hi All,
> >
> > I am sure this is not as difficult as my man flu addled brain is making it.
> >
> > I have a number of worksheets in a workbook that have the relevant
> > information I want to copy in the same range (A71:I71). I then have a
> > seperate workbook that I want to paste the values onto the next blank row, so
> > I can make a summary page.
> >
> > The following code is what I have cobbled together from various posts (Kudos
> > to those who may recognise bits of their code! I know some of it came from
> > Ron db)
> >
> > The source ranges will be present on all of the worksheets within the
> > workbook but will all have different names and the number of worksheets will
> > differ everytime this macro is run. The code seems to fall down as it only
> > copy & pastes from the first worksheet and then seems to ignore the rest!
> >
> > The source worksheets are in a password protected workbook (that bit works
> > fine!)
> >
> > Any help greatly appreciated.
> >
> > Sub CopyDetails()
> >
> > Dim wbk As Workbook
> > Dim sh As Worksheet
> > Dim Sourcewb As Workbook
> >
> > Set wbk = Workbooks.Open(Filename:="filelocation", UpdateLinks:=True,
> > Password:="password")
> > Set Sourcewb = ThisWorkbook
> >
> > For Each sh In Sourcewb.Worksheets
> > Range("A71:I71").Copy Destination:=Workbooks("Report").Worksheets("TM
> > Overview").Cells(Rows.Count, 1).End(xlUp)(2)
> > Next sh
> >
> > End Sub

>
> --
>
> Dave Peterson
> .
>

 
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
How to copy a range of cells and paste into a new workbook in differentcolumns Mas Microsoft Excel Misc 3 16th Aug 2011 02:57 PM
Column range to search from a source workbook and then copy/paste DanS Microsoft Excel Programming 0 10th Feb 2009 11:29 PM
Copy paste a range from one Workbook to another Kc-Mass Microsoft Excel Programming 2 13th Dec 2006 01:18 AM
Need a macro to copy a range in one workbook and paste into another workbook Paul Microsoft Excel Programming 8 1st Jul 2004 07:42 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Microsoft Excel Programming 3 24th Jun 2004 12:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:20 AM.