Copying Formula

M

Michael

Hi all,

Is it possible to copy a formula using a macro from a
selected cell in a range to the cell directly above it?
without having to actually code the cell reference each
time?

The range I refer to can have rows deleted and inserted by
the user, thus the cell references will constantly change.

Thanks for your help


Michael
 
A

Abdul Salam

Sub test()

ActiveCell.Copy
ActiveCell.Offset(-1, 0).PasteSpecial
Paste:=xlPasteFormulas
End Sub

Abdul Salam
 
D

Donald Lloyd

Hi Michael,

If the formula components are all relative you can make a straight copy as
follows.

Sub CopyUp1Cell()
ActiveCell.Copy ActiveCell.Offset(-1, 0)
End Sub

The above works on the activecell, but you can refer to it as you wish.

e.g. Range("H20"), cells(20, 8)

regards,
Don
 

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