copy formula using VB code

A

ASU

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

T Kirtley

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
 
A

ASU

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
 
Top