PC Review


Reply
Thread Tools Rate Thread

Copy & Paste Named Range Contents

 
 
BJ
Guest
Posts: n/a
 
      1st Aug 2008
How do I copy and paste the 'contents' of a Named Range via VBA? I don't
want to copy and paste the range name.

For example, if the Named Range 'Table' is cells A1:F10 of Sheet name
'Data', how do I code in VBA the ability to paste the contents of 'Table'
into sheet name 'Summary' starting at cell G10?

Thank you.
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Aug 2008
Try this statement...

Range("Table").Copy Worksheets("Summary").Range("G10")

Rick


"BJ" <(E-Mail Removed)> wrote in message
news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
> How do I copy and paste the 'contents' of a Named Range via VBA? I don't
> want to copy and paste the range name.
>
> For example, if the Named Range 'Table' is cells A1:F10 of Sheet name
> 'Data', how do I code in VBA the ability to paste the contents of 'Table'
> into sheet name 'Summary' starting at cell G10?
>
> Thank you.


 
Reply With Quote
 
BJ
Guest
Posts: n/a
 
      1st Aug 2008
Thanks Rick - worked great - but I forgot to mention that I need to transpose
the data. How do I work in the PasteSpecial code?

"Rick Rothstein (MVP - VB)" wrote:

> Try this statement...
>
> Range("Table").Copy Worksheets("Summary").Range("G10")
>
> Rick
>
>
> "BJ" <(E-Mail Removed)> wrote in message
> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
> > How do I copy and paste the 'contents' of a Named Range via VBA? I don't
> > want to copy and paste the range name.
> >
> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet name
> > 'Data', how do I code in VBA the ability to paste the contents of 'Table'
> > into sheet name 'Summary' starting at cell G10?
> >
> > Thank you.

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Aug 2008
That was a big item to forget.<g> Try it this way then...

Range("Table").Copy
Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
Application.CutCopyMode = False

Rick


"BJ" <(E-Mail Removed)> wrote in message
news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
> Thanks Rick - worked great - but I forgot to mention that I need to
> transpose
> the data. How do I work in the PasteSpecial code?
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> Try this statement...
>>
>> Range("Table").Copy Worksheets("Summary").Range("G10")
>>
>> Rick
>>
>>
>> "BJ" <(E-Mail Removed)> wrote in message
>> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
>> > How do I copy and paste the 'contents' of a Named Range via VBA? I
>> > don't
>> > want to copy and paste the range name.
>> >
>> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet name
>> > 'Data', how do I code in VBA the ability to paste the contents of
>> > 'Table'
>> > into sheet name 'Summary' starting at cell G10?
>> >
>> > Thank you.

>>
>>


 
Reply With Quote
 
BJ
Guest
Posts: n/a
 
      1st Aug 2008
I know ... I'm a forgetful putz ... my wife would agree ... =)

When I use the code I'm getting a VBA error ...

With the word 'Transpose' highlighted the dialog box indicates:
Compile Error: Expected: end of statement

Is there a space between 'PasteSpecial' and 'Transpose'? (That's when I get
the error message). If I remove the space I get the same error but the ':='
is now highlighted instead.

My apologies for my stupidity.

bj

"Rick Rothstein (MVP - VB)" wrote:

> That was a big item to forget.<g> Try it this way then...
>
> Range("Table").Copy
> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
> Application.CutCopyMode = False
>
> Rick
>
>
> "BJ" <(E-Mail Removed)> wrote in message
> news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
> > Thanks Rick - worked great - but I forgot to mention that I need to
> > transpose
> > the data. How do I work in the PasteSpecial code?
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> Try this statement...
> >>
> >> Range("Table").Copy Worksheets("Summary").Range("G10")
> >>
> >> Rick
> >>
> >>
> >> "BJ" <(E-Mail Removed)> wrote in message
> >> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
> >> > How do I copy and paste the 'contents' of a Named Range via VBA? I
> >> > don't
> >> > want to copy and paste the range name.
> >> >
> >> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet name
> >> > 'Data', how do I code in VBA the ability to paste the contents of
> >> > 'Table'
> >> > into sheet name 'Summary' starting at cell G10?
> >> >
> >> > Thank you.
> >>
> >>

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Aug 2008
Sorry, I should have included the worksheet reference for the Table. Try
this...

Worksheets("Data").Range("Table").Copy
Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
Application.CutCopyMode = False

Rick


"BJ" <(E-Mail Removed)> wrote in message
news:EB2E2776-7E72-4BD1-8F34-(E-Mail Removed)...
>I know ... I'm a forgetful putz ... my wife would agree ... =)
>
> When I use the code I'm getting a VBA error ...
>
> With the word 'Transpose' highlighted the dialog box indicates:
> Compile Error: Expected: end of statement
>
> Is there a space between 'PasteSpecial' and 'Transpose'? (That's when I
> get
> the error message). If I remove the space I get the same error but the
> ':='
> is now highlighted instead.
>
> My apologies for my stupidity.
>
> bj
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> That was a big item to forget.<g> Try it this way then...
>>
>> Range("Table").Copy
>> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
>> Application.CutCopyMode = False
>>
>> Rick
>>
>>
>> "BJ" <(E-Mail Removed)> wrote in message
>> news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
>> > Thanks Rick - worked great - but I forgot to mention that I need to
>> > transpose
>> > the data. How do I work in the PasteSpecial code?
>> >
>> > "Rick Rothstein (MVP - VB)" wrote:
>> >
>> >> Try this statement...
>> >>
>> >> Range("Table").Copy Worksheets("Summary").Range("G10")
>> >>
>> >> Rick
>> >>
>> >>
>> >> "BJ" <(E-Mail Removed)> wrote in message
>> >> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
>> >> > How do I copy and paste the 'contents' of a Named Range via VBA? I
>> >> > don't
>> >> > want to copy and paste the range name.
>> >> >
>> >> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet
>> >> > name
>> >> > 'Data', how do I code in VBA the ability to paste the contents of
>> >> > 'Table'
>> >> > into sheet name 'Summary' starting at cell G10?
>> >> >
>> >> > Thank you.
>> >>
>> >>

>>
>>


 
Reply With Quote
 
BJ
Guest
Posts: n/a
 
      1st Aug 2008
Hi Rick - many many thanks ...

I've got some empty columns as part of my named range. When the range is
copied, the blank columns are removed. Is that a permanent issue or is there
a workaround?

"Rick Rothstein (MVP - VB)" wrote:

> Sorry, I should have included the worksheet reference for the Table. Try
> this...
>
> Worksheets("Data").Range("Table").Copy
> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
> Application.CutCopyMode = False
>
> Rick
>
>
> "BJ" <(E-Mail Removed)> wrote in message
> news:EB2E2776-7E72-4BD1-8F34-(E-Mail Removed)...
> >I know ... I'm a forgetful putz ... my wife would agree ... =)
> >
> > When I use the code I'm getting a VBA error ...
> >
> > With the word 'Transpose' highlighted the dialog box indicates:
> > Compile Error: Expected: end of statement
> >
> > Is there a space between 'PasteSpecial' and 'Transpose'? (That's when I
> > get
> > the error message). If I remove the space I get the same error but the
> > ':='
> > is now highlighted instead.
> >
> > My apologies for my stupidity.
> >
> > bj
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> That was a big item to forget.<g> Try it this way then...
> >>
> >> Range("Table").Copy
> >> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
> >> Application.CutCopyMode = False
> >>
> >> Rick
> >>
> >>
> >> "BJ" <(E-Mail Removed)> wrote in message
> >> news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
> >> > Thanks Rick - worked great - but I forgot to mention that I need to
> >> > transpose
> >> > the data. How do I work in the PasteSpecial code?
> >> >
> >> > "Rick Rothstein (MVP - VB)" wrote:
> >> >
> >> >> Try this statement...
> >> >>
> >> >> Range("Table").Copy Worksheets("Summary").Range("G10")
> >> >>
> >> >> Rick
> >> >>
> >> >>
> >> >> "BJ" <(E-Mail Removed)> wrote in message
> >> >> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
> >> >> > How do I copy and paste the 'contents' of a Named Range via VBA? I
> >> >> > don't
> >> >> > want to copy and paste the range name.
> >> >> >
> >> >> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet
> >> >> > name
> >> >> > 'Data', how do I code in VBA the ability to paste the contents of
> >> >> > 'Table'
> >> >> > into sheet name 'Summary' starting at cell G10?
> >> >> >
> >> >> > Thank you.
> >> >>
> >> >>
> >>
> >>

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Aug 2008
Hmm! I'm not sure what to tell you as that does not happen on my XL2003
system... blank columns become blank rows after the transpose. Do you have
any other code running along with what I posted? If so, could you show it to
us?

Rick


"BJ" <(E-Mail Removed)> wrote in message
news:1BECD7FA-9D04-42C9-A8EC-(E-Mail Removed)...
> Hi Rick - many many thanks ...
>
> I've got some empty columns as part of my named range. When the range is
> copied, the blank columns are removed. Is that a permanent issue or is
> there
> a workaround?
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> Sorry, I should have included the worksheet reference for the Table. Try
>> this...
>>
>> Worksheets("Data").Range("Table").Copy
>> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
>> Application.CutCopyMode = False
>>
>> Rick
>>
>>
>> "BJ" <(E-Mail Removed)> wrote in message
>> news:EB2E2776-7E72-4BD1-8F34-(E-Mail Removed)...
>> >I know ... I'm a forgetful putz ... my wife would agree ... =)
>> >
>> > When I use the code I'm getting a VBA error ...
>> >
>> > With the word 'Transpose' highlighted the dialog box indicates:
>> > Compile Error: Expected: end of statement
>> >
>> > Is there a space between 'PasteSpecial' and 'Transpose'? (That's when
>> > I
>> > get
>> > the error message). If I remove the space I get the same error but the
>> > ':='
>> > is now highlighted instead.
>> >
>> > My apologies for my stupidity.
>> >
>> > bj
>> >
>> > "Rick Rothstein (MVP - VB)" wrote:
>> >
>> >> That was a big item to forget.<g> Try it this way then...
>> >>
>> >> Range("Table").Copy
>> >> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
>> >> Application.CutCopyMode = False
>> >>
>> >> Rick
>> >>
>> >>
>> >> "BJ" <(E-Mail Removed)> wrote in message
>> >> news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
>> >> > Thanks Rick - worked great - but I forgot to mention that I need to
>> >> > transpose
>> >> > the data. How do I work in the PasteSpecial code?
>> >> >
>> >> > "Rick Rothstein (MVP - VB)" wrote:
>> >> >
>> >> >> Try this statement...
>> >> >>
>> >> >> Range("Table").Copy Worksheets("Summary").Range("G10")
>> >> >>
>> >> >> Rick
>> >> >>
>> >> >>
>> >> >> "BJ" <(E-Mail Removed)> wrote in message
>> >> >> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
>> >> >> > How do I copy and paste the 'contents' of a Named Range via VBA?
>> >> >> > I
>> >> >> > don't
>> >> >> > want to copy and paste the range name.
>> >> >> >
>> >> >> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet
>> >> >> > name
>> >> >> > 'Data', how do I code in VBA the ability to paste the contents of
>> >> >> > 'Table'
>> >> >> > into sheet name 'Summary' starting at cell G10?
>> >> >> >
>> >> >> > Thank you.
>> >> >>
>> >> >>
>> >>
>> >>

>>
>>


 
Reply With Quote
 
BJ
Guest
Posts: n/a
 
      1st Aug 2008
Sometimes even my stupidity astounds me ... I had left the transpose = true
statement in ... maybe it's time to go outside and enjoy the 90 degree MN
summer for a while ... =)

Many thanks again Rick - your responsiveness on this board is truly a
blessing ...

"Rick Rothstein (MVP - VB)" wrote:

> Hmm! I'm not sure what to tell you as that does not happen on my XL2003
> system... blank columns become blank rows after the transpose. Do you have
> any other code running along with what I posted? If so, could you show it to
> us?
>
> Rick
>
>
> "BJ" <(E-Mail Removed)> wrote in message
> news:1BECD7FA-9D04-42C9-A8EC-(E-Mail Removed)...
> > Hi Rick - many many thanks ...
> >
> > I've got some empty columns as part of my named range. When the range is
> > copied, the blank columns are removed. Is that a permanent issue or is
> > there
> > a workaround?
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> Sorry, I should have included the worksheet reference for the Table. Try
> >> this...
> >>
> >> Worksheets("Data").Range("Table").Copy
> >> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
> >> Application.CutCopyMode = False
> >>
> >> Rick
> >>
> >>
> >> "BJ" <(E-Mail Removed)> wrote in message
> >> news:EB2E2776-7E72-4BD1-8F34-(E-Mail Removed)...
> >> >I know ... I'm a forgetful putz ... my wife would agree ... =)
> >> >
> >> > When I use the code I'm getting a VBA error ...
> >> >
> >> > With the word 'Transpose' highlighted the dialog box indicates:
> >> > Compile Error: Expected: end of statement
> >> >
> >> > Is there a space between 'PasteSpecial' and 'Transpose'? (That's when
> >> > I
> >> > get
> >> > the error message). If I remove the space I get the same error but the
> >> > ':='
> >> > is now highlighted instead.
> >> >
> >> > My apologies for my stupidity.
> >> >
> >> > bj
> >> >
> >> > "Rick Rothstein (MVP - VB)" wrote:
> >> >
> >> >> That was a big item to forget.<g> Try it this way then...
> >> >>
> >> >> Range("Table").Copy
> >> >> Worksheets("Summary").Range("G10").PasteSpecial Transpose:=True
> >> >> Application.CutCopyMode = False
> >> >>
> >> >> Rick
> >> >>
> >> >>
> >> >> "BJ" <(E-Mail Removed)> wrote in message
> >> >> news:B633B8F8-87F6-4E5E-B2BD-(E-Mail Removed)...
> >> >> > Thanks Rick - worked great - but I forgot to mention that I need to
> >> >> > transpose
> >> >> > the data. How do I work in the PasteSpecial code?
> >> >> >
> >> >> > "Rick Rothstein (MVP - VB)" wrote:
> >> >> >
> >> >> >> Try this statement...
> >> >> >>
> >> >> >> Range("Table").Copy Worksheets("Summary").Range("G10")
> >> >> >>
> >> >> >> Rick
> >> >> >>
> >> >> >>
> >> >> >> "BJ" <(E-Mail Removed)> wrote in message
> >> >> >> news:3BB47A4F-6840-44DA-9DEC-(E-Mail Removed)...
> >> >> >> > How do I copy and paste the 'contents' of a Named Range via VBA?
> >> >> >> > I
> >> >> >> > don't
> >> >> >> > want to copy and paste the range name.
> >> >> >> >
> >> >> >> > For example, if the Named Range 'Table' is cells A1:F10 of Sheet
> >> >> >> > name
> >> >> >> > 'Data', how do I code in VBA the ability to paste the contents of
> >> >> >> > 'Table'
> >> >> >> > into sheet name 'Summary' starting at cell G10?
> >> >> >> >
> >> >> >> > Thank you.
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >>
> >>

>
>

 
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
copy named range & paste values J.W. Aldridge Microsoft Excel Programming 2 1st Mar 2010 09:59 PM
copy named range & paste J.W. Aldridge Microsoft Excel Programming 2 8th Oct 2009 04:38 PM
Named range row copy/paste problem John Microsoft Excel Programming 1 2nd Feb 2009 06:27 PM
Copy and Paste 2 columns from a named range? Simon Lloyd Microsoft Excel Programming 2 28th May 2006 08:10 PM
Copy named range contents to activecell position =?Utf-8?B?TmVhbA==?= Microsoft Excel Programming 2 28th Oct 2004 02:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:14 AM.