Copy Formulas

arnapsui

Board Regular
Joined
Mar 16, 2010
Messages
55
Hi

I have numbers of sheets in workbook and I have entered a formula in a cell. Each sheets are holding different number of rows with data. I want a macro to copy the formula from the cell to and paste it till the ned of row with data in a partcular column.

Example:
Formula in Cell B4

Sheet1: Number of rows 20, I need to copy and paste till B20

Sheet2: Number of rows 15, I need to copy and paste till B15

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
Assuming that the formula already exists in B4 of each sheet try

Code:
Sub FillFormula()
Dim LR As Long, ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    If LR > 4 Then .Range("B4").AutoFill Destination:=.Range("B4:B" & LR)
Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

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