You are here:

- Home
- Computing/Technology
- Business Software
- Excel
- Copy Formula

Advertisement

Good day Bob,

I'm trying to only the Formula of a range but it copies also the Value.

The tricky part is that in the range to be copied, some cells contains FORMULA and some don't.

Here is a test file that I have used to test the code

Sub TestCopyOnlyFormula()

Application.EnableEvents = False

Range("D500:R550").Clear

Range("D10:R10").Select

Selection.Copy

Range("D500:R550").Select

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

Application.EnableEvents = True

End Sub

I'm I doing something wrong?

Is there an alternative to copy the Formula only?

Thank you.

No - the formula is just evaluating. For example, if cell A1 has 25 in it and cell A2 has 28 in it, and cell B1 has =A1 in it, if you copy B1 and paste only the formula to B2, you'll still see 28 because the formula has =A2, and that evaluates to 28. If you turn calculations off you'll see the 25 instead of 28, but the formula still evaulates to some value.

Also, your code could be shortened to this (no need to select):

Sub TestCopyOnlyFormula()

Application.EnableEvents = False

Range("D10:R10").Copy

Range("D500:R550").PasteSpecial Paste:=xlPasteFormulas

Application.EnableEvents = True

End Sub

- Add to this Answer
- Ask a Question

Rating(1-10) | Knowledgeability = 10 | Clarity of Response = 10 | Politeness = 10 |

Comment | No Comment |

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

Answers by Expert:

I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at http://www.thumbtack.com/ny/new-york/excel-training/

Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."**Publications**

Excellence, The Expert, Microsoft**Education/Credentials**

BA in math, Hofstra University, 1965**Awards and Honors**

MVP

Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks