Stopping an insert formula macro when the data stops

TheHeape

New Member
Joined
May 27, 2011
Messages
2
I use a macro to insert a formula down a selected column. The data feild changes length every day so my macro either runs to far down which creates blank cells to print or not far enough so I have to manually extend its length. There is the occasional blank row that needs to be skipped but never more than 1, here is my current code.

Code:
    ActiveCell.FormulaR1C1 = "UPC"
    Range("P3").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-6]="""","""",((RC[-5]+RC[-4])/RC[-3]))"
    Selection.AutoFill Destination:=Range("P3:P82"), Type:=xlFillDefault
    Range("P3:P82").Select
    Selection.NumberFormat = "0.00"
    ActiveWindow.SmallScroll Down:=-100
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,559
Messages
6,179,517
Members
452,921
Latest member
BBQKING

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