Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do i paste a range?

I have a range, D10:O12, D20:O22, and I would like to be able to cop
the range and paste it to another sheet in the same exact cells that
copied it from. So far, I've unioned the ranges together and I've trie
using .Copy method but that doesn't allow me to copy multiple ranges
Is there any way i can do this without having to write code t
explicitly state where each range goes? because in actuality, i hav
about 30 different ranges I need to perform this action on.

On a side note, i've noticed and been told that copying/pasting tw
different ranges from worksheet to another at the same time does no
preserve the spacing between the ranges in the first place. s
hopefully there's some way to do this in VBA without having to copy an
paste one range at a time

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default how do i paste a range?

You should be able to use the Areas collection of the
selected range(s) to deal with each separate 'block' of
contiguous cells. I will assume you have selected the
desired ranges, and you want to move them all to the sheet
called "NewSheet":

Dim xlRange as Range, strAddress as String

For Each xlRange in Selection.Areas
strAddress = xlRange.Address
xlRange.Copy
Sheets("NewSheet").Range(strAddress).PasteSpecial
Next xlRange

Technically you are copying and pasting one range at a
time (which you wanted to avoid), but VBA takes care of
this nicely and the code is pretty compact.

Hope this does the trick for you.

K Dales

-----Original Message-----
I have a range, D10:O12, D20:O22, and I would like to be

able to copy
the range and paste it to another sheet in the same exact

cells that I
copied it from. So far, I've unioned the ranges together

and I've tried
using .Copy method but that doesn't allow me to copy

multiple ranges.
Is there any way i can do this without having to write

code to
explicitly state where each range goes? because in

actuality, i have
about 30 different ranges I need to perform this action

on.

On a side note, i've noticed and been told that

copying/pasting two
different ranges from worksheet to another at the same

time does not
preserve the spacing between the ranges in the first

place. so
hopefully there's some way to do this in VBA without

having to copy and
paste one range at a time.


---
Message posted from http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy & paste range nc Excel Discussion (Misc queries) 0 July 16th 09 06:58 PM
copy range and paste into every 3rd cell of new range thomsonpa New Users to Excel 4 December 3rd 07 01:47 PM
Prevent cut and paste over a range andy62 Excel Worksheet Functions 0 June 30th 07 04:22 AM
Paste a named range to another range in Excel David Jean Excel Discussion (Misc queries) 2 April 13th 05 02:02 PM
Paste a Range from a variable Al[_11_] Excel Programming 3 October 28th 03 06:04 PM


All times are GMT +1. The time now is 07:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"