copy formula using VB code

G

Guest

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

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top