Thread: Copy Formulas
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
David McRitchie[_2_] David McRitchie[_2_] is offline
external usenet poster
 
Posts: 134
Default Copy Formulas

If you want to do this often Chip Pearson posted code for a macro
to be used as a right click menu. You have to install it into your
workbook. Refer to the links so you install code into your
Auto_Open macro.

Sub CopyFormula()
'Chip Pearson, microsoft.public.excel.worksheet.functions, 2000/05/02
' http://groups.google.com/groups?hl=e...19367&rnum= 1
' http://groups.google.com/groups?as_u...12@tkmsftngp05
Dim x As New DataObject
x.SetText ActiveCell.Formula
x.PutInClipboard
End Sub

Sub PasteFormula()
On Error Resume Next
Dim x As New DataObject
x.GetFromClipboard
ActiveCell.Formula = x.GetText
End Sub

'--- add this code to your Auto_Open
'Chip Pearson via Drew Paterson -- 2001-04-13 misc
'--http://groups.google.com/groups?threadm=uiqh89AxAHA.1620%40tkmsftngp05
Application.CommandBars("Cell").Reset 'was not in 2001-04-13 posting
With Application.CommandBars("Cell").Controls
With .Add
.Caption = "C&opy Formula"
.OnAction = ThisWorkbook.Name & "!CopyFormula"
.Tag = "Formulas" 'cControlTag
.BeginGroup = True
End With

With .Add
.Caption = "P&aste Formula"
.OnAction = ThisWorkbook.Name & "!PasteFormula"
.Tag = "Formulas2" 'cControlTag
End With
End With
'instead of Auto_Open use Workbook_Open in the ThisWorklbook
' when you need to fire off a macro when opening with code.


--
---
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

"AJ" wrote in message ...
I have some values which are derived from a formula. I am
trying to paste those values on another sheet and want
then to use the exact same formula . how can do that
without having absolte cell reference?
Thanks
AJ