ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   copy formula using VB code (https://www.excelbanter.com/excel-discussion-misc-queries/107608-copy-formula-using-vbulletin-code.html)

ASU

copy formula using VB code
 
How do you copy and paste (using VB code) a cell formula to a newly created
spreadsheet.
--
ASU

T Kirtley

copy formula using VB code
 
Would something like the following work?

Sub CopyFormula()
Dim Frm As String
Frm = ActiveCell.Formula
Worksheets.Add
Range("A1").Formula = Frm
End Sub

You no doubt would want to add more code but this may get you started.

HTH,

TK

"ASU" wrote:

How do you copy and paste (using VB code) a cell formula to a newly created
spreadsheet.
--
ASU


ASU

copy formula using VB code
 
Thanks very much. Unfortunately I have changed the form slightly.
What I could do with now is a code that would copy and paste the formula,
say in cell "H11", and paste it in the next cell "H12". and when cell "H12"
is filled with a value, the formula is pasted to the next cell("H13"), and so
on.
I hope it's clear.
Thank you
--
ASU


"T Kirtley" wrote:

Would something like the following work?

Sub CopyFormula()
Dim Frm As String
Frm = ActiveCell.Formula
Worksheets.Add
Range("A1").Formula = Frm
End Sub

You no doubt would want to add more code but this may get you started.

HTH,

TK

"ASU" wrote:

How do you copy and paste (using VB code) a cell formula to a newly created
spreadsheet.
--
ASU



All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com