Help with offset for pasting formulas

mlibrett

New Member
Joined
Aug 11, 2011
Messages
12
I have a formula in one cell, and I need to write the code so that it copies and pastes this formula into the 8 cells beneath it without specifying the actual cells. I'm assuming some sort of offset code would work but I don't know where to begin or find this.

Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the board. Something like this:
Code:
Sub copy()
Application.ScreenUpdating = False
With Range("A1") 'change cell reference as required
    .copy Range(.Offset(1), .Offset(8))
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I have a formula in one cell, and I need to write the code so that it copies and pastes this formula into the 8 cells beneath it without specifying the actual cells. I'm assuming some sort of offset code would work but I don't know where to begin or find this.
You didn't say which cell, so I used the ActiveCell (change the two references to it to the cell reference you want)... this single line of code should do what you described you want.

Code:
ActiveCell.Resize(9).Formula = ActiveCell.Formula
Note the use of 9 is correct as it is the ActiveCell plus the 8 cells underneath it for a total of 9 cells.
 
Upvote 0
Thanks for the help! I'll try messing around with those now. What does Application Updating do?
When you set Application.ScreenUpdating to False, all screen display activity (within Excel) is halted, so any anything you code puts into cells won't display until you turn ScreenUpdating back on (setting it to True)... doing this helps speed up code. It is more useful in large looping code. I have found that for the number of cells most people work with, multi-cell range copying and multi-cell direct range assignments usually do not need this assist... I would say it is really not necessary for copying a total of eight cells.
 
Upvote 0
That worked, thanks a lot!
I'm not sure which one you were referring to when you said "that worked", but just so you know, both njimack's and my code will do what you asked... it is just two different methods to achieve the same end goal.
 
Upvote 0
ActiveCell.Resize(9).Formula for this one, do I have to put the formula myself or it will know to take the formula in the active cell?
 
Upvote 0
ActiveCell.Resize(9).Formula for this one, do I have to put the formula myself or it will know to take the formula in the active cell?
Use the code line exactly as I posted it... it will automatically pull the formula from the active cell and copy it back into itself while at the same time copy it into the eight cells underneath it.
 
Upvote 0

Forum statistics

Threads
1,216,175
Messages
6,129,312
Members
449,499
Latest member
HockeyBoi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top