|
-
Jul 13th, 2005, 05:23 PM
#1
Thread Starter
Hyperactive Member
Copying a Ranges Values Only
Hi,
I am trying to write a VBA subroutine that is activated by a button and that copies the contents of one range to another.
For the sake of argument lets say I am trying to copy data from a range called Source_Range to a range called Destination_Range.
The problem I am having is that the source range contains formulas in each cell, and I only want to copy the results (numbers) of those formulas to the destination range. But if I use the following code:
VB Code:
Range("Source_Range").Copy Range("Destination_Range")
...it just copies the formulas as well.
If I use this code:
VB Code:
Range("Source_Range").Copy
Range("Destinaton_Range").Select
Selection.PasteSpecial Paste:=xlPasteValues
...it works, but it also has to select the destination range in order for it to work.
What I really want is a way to PasteSpecial the values only but without having to actually select any of the ranges, as in the first set of code (only this also copies the formulas, which isn't what I want).
Is there anyway to do this? Or does PasteSpecial always require that you select the range that you want to paste to? Is there an alternative to PasteSpecial that I could use?
Thanks in advance
-Rob
*Edit*
I also tried this, which I thought would work but it doesn't actually seem to do anything (it doesn't produce an error either, it just does nothing):
VB Code:
Range("Destination_Range") = Range("Source_Range")
Why doesn't this work? I thought it would do, since it works for individual cells, but not for named ranges?!?!
Last edited by TheRobster; Jul 13th, 2005 at 05:33 PM.
http://www.sudsolutions.com
-
Jul 14th, 2005, 02:47 AM
#2
Re: Copying a Ranges Values Only
Code:
Range("Source_Range").Copy
Range("Destinaton_Range").PasteSpecial Paste:=xlPasteValues
Did you try the above?
Are Source_Range and DEstination_Range variables or named ranges?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 14th, 2005, 06:44 AM
#3
Junior Member
Re: Copying a Ranges Values Only
Have you tried something like
VB Code:
Range(InCell1, InCell2).Value = Range(OutCell1, OutCell2).Value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|