Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default cannot copy formulas only

I use this line in my macro

Range("b2:z2").Select
Application.CutCopyMode = False
Selection.Copy
Range(doel).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Some how excel copies also the values.
What am i doing wrong?
Greetings Hans



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default cannot copy formulas only

Hi Hans,

You aren't doing anything wrong, this is how PasteSpecial/Formulas
works. If the copied cell contains a formula, the formula is pasted. If the
copied cell contains a value, the value is pasted. What you can do is delete
the values after you paste special. Something like this:

Range("b2:z2").Copy
Range(doel).PasteSpecial Paste:=xlPasteFormulas
On Error Resume Next
Range(doel).Resize(1, 25) _
.SpecialCells(xlCellTypeConstants, 23).ClearContents
On Error GoTo 0

The On Error Resume Next/On Error GoTo 0 around the SpecialCells method
is required because it will error if you copy and paste a range that
contains only formulas. If you know there will always be values in the
copied range you can remove these two lines.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"hans" wrote in message
...
I use this line in my macro

Range("b2:z2").Select
Application.CutCopyMode = False
Selection.Copy
Range(doel).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Some how excel copies also the values.
What am i doing wrong?
Greetings Hans





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default cannot copy formulas only

Thank for the info

Greetings Hans

"Rob Bovey" schreef in bericht
...
Hi Hans,

You aren't doing anything wrong, this is how PasteSpecial/Formulas
works. If the copied cell contains a formula, the formula is pasted. If

the
copied cell contains a value, the value is pasted. What you can do is

delete
the values after you paste special. Something like this:

Range("b2:z2").Copy
Range(doel).PasteSpecial Paste:=xlPasteFormulas
On Error Resume Next
Range(doel).Resize(1, 25) _
.SpecialCells(xlCellTypeConstants, 23).ClearContents
On Error GoTo 0

The On Error Resume Next/On Error GoTo 0 around the SpecialCells

method
is required because it will error if you copy and paste a range that
contains only formulas. If you know there will always be values in the
copied range you can remove these two lines.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"hans" wrote in message
...
I use this line in my macro

Range("b2:z2").Select
Application.CutCopyMode = False
Selection.Copy
Range(doel).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Some how excel copies also the values.
What am i doing wrong?
Greetings Hans







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 Formulas Loren Excel Discussion (Misc queries) 1 October 22nd 09 05:17 PM
automatically copy formulas down columns or copy formulas all the HowlingBlue Excel Worksheet Functions 1 March 16th 07 11:11 PM
How do I copy formulas but using the same range each time I copy Laffin Excel Worksheet Functions 2 June 22nd 06 04:17 PM
Copy Value not formulas sungen99 Excel Worksheet Functions 1 January 3rd 06 03:51 PM
Range COPY function - how to copy VALUES and not formulas James Cooke Excel Programming 1 August 21st 03 07:04 PM


All times are GMT +1. The time now is 04:31 PM.

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"