Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How can I paste formulas only an not values

So your selection is a combination of constants and formulas?

If yes, copy the range, paste the formulas and then clear the constants from
that pasted range.

Something like:

dim rng as range
dim destcell as range

set rng = selection
set destcell = worksheets("sheet1").range("a1")

rng.copy
destcell.pastespecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

on error resume next
destcell.resize(rng.rows.count,rng.columns.count) _
.cells.specialcells(xlcelltypeconstants).clearcont ents
on error goto 0



RAD wrote:

In a script I want to copy only formulas, not values.

Currently I use this code for the 'paste' operation, but this also copy raw
values, what I do not want.

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Thanks


--

Dave Peterson
  #2   Report Post  
Posted to microsoft.public.excel.programming
RAD RAD is offline
external usenet poster
 
Posts: 13
Default How can I paste formulas only an not values

In a script I want to copy only formulas, not values.

Currently I use this code for the 'paste' operation, but this also copy raw
values, what I do not want.

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Thanks
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How can I paste formulas only an not values

Raw values are considered formulas for the purpose of pasting. So you would
have to avoid copying cells that contain constants.


selection.Specialcells(xlformulas).copy

will just copy cells with formulas - however, it will skip the cells it
doesn't copy and this may not be what you want.

you could paste the original selection as you are doing, then clear out the
constants

set rng = selection
rng.copy Range("Z100")
Range("Z100").Resize(rng.rows.count, _
rng.columns.count).specialcells(xlconstants).clear

--
Regards,
Tom Ogilvy






"RAD" wrote in message
...
In a script I want to copy only formulas, not values.

Currently I use this code for the 'paste' operation, but this also copy

raw
values, what I do not want.

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default How can I paste formulas only an not values

Try

dim targetcell as range
dim sourcecell as range

targetcell.formula = sourcecell.formula

by passes the clipboard and easier to read

"RAD" wrote:

In a script I want to copy only formulas, not values.

Currently I use this code for the 'paste' operation, but this also copy raw
values, what I do not want.

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default How can I paste formulas only an not values

From the other answers and since they all seem to lead in about
the same direction, it might be possible that you are trying to do something
like the first macro, InsertRowsAndFillFormulas in
http://www.mvps.org/dmcritchie/excel/insrtrows.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"RAD" wrote in message ...
In a script I want to copy only formulas, not values.

Currently I use this code for the 'paste' operation, but this also copy raw
values, what I do not want.

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Thanks



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 and paste values, formatting and formulas Joe M. Excel Discussion (Misc queries) 2 February 29th 08 09:38 PM
how can I paste values derived from formulas into a different book deepdale1881 Excel Worksheet Functions 3 May 7th 07 05:34 PM
copied formulas paste as values Trev Excel Discussion (Misc queries) 2 February 11th 06 05:09 AM
Can you copy multiple tabs from formulas to values w/o paste spec? Brent Excel Worksheet Functions 2 October 27th 05 12:47 AM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 05:46 PM.

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

About Us

"It's about Microsoft Excel"