Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pasting formulae only 1

Status
Not open for further replies.

GMoyle

Programmer
Jul 13, 2001
7
GB
I want to copy a range of cells in excel but only paste those that contain formulae. Is this possible?

Thanks.
 
It is possible through a VBA Macro:

The macro below will run through whichever range you set as [MyRange] e.g."A1:A20" & paste the formulae into column B

Sub PasteOnlyFormulae()

For each x in range([MyRange]).cells
CurrRow = x.row
Target = "B" & CurrRow
if x.HasFormula = True then
x.copy
Range(Target).PasteSpecial xlPasteFormulas
End If
Next x

End Sub


Store300

Store300@ftnetwork.com
 
hiya

You can also do it without VBA by using Edit, Goto and clicking the Special button then choosing to select (Goto) formulas only. Then just copy and paste them.

HTH,
pjm
 
The only drawback with that is that is will overwrite any values inbetween the formulae but if that isn't a problem then pjm's method is a darn sight easier. :) Store300

Store300@ftnetwork.com
 
After copying the range of cells, instead of choosing PASTE, Choose PASTE SPECIAL. in this method you can choose what you want to paste, like FORMULA or VALUES.

Try it will work..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top