Copy and Paste Formula from ActiveCell to cells in 13 columns priorto the active column

S

sgltaylor

Hi All,

I have a sum formula in cell Z30. I am trying to figure out how to
copy the sum formula and paste it into the 13 columns immediately
before column Z. The trick is that I will not always be starting from
column Z and not always on the same row either. At times, it may be
column AA10 or AD50 etc so the code need to be able handle this.

Any ideas?

Thanks,

Steve
 
G

Gary''s Student

Sub CopyFormula()
Set r1 = ActiveCell
rr = r1.Row
rc = r1.Column
Set r2 = Range(Cells(rr, rc - 1), Cells(rr, rc - 13))
r1.Copy r2
End Sub

This will copy the active celll to the 13 cells immediate adjacent to the
left. There is a shorter method using Offset().
 

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