Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Fill down to last row - copy formula to last row
Dear Friends,
Once again I turn to you! I have a pivot table that will be generating several reports whereas the columns and rows will change with every selection. I need to have formulas placed at the end of the columns and copied down to the last row after page value is changed. I've got everything to work except for copying the formula down to the last row (the last line of code is where it's crashing..) see below: Sub SetUpFormula() Dim strLstRw As String strLstRw = ActiveSheet.Range("A65000").End(xlUp).Row Range("D4").Select Selection.End(xlToRight).Select ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "Rate" ActiveCell.Offset(1, 0).Select ActiveCell.Formula = _ "=IF(ISERROR(VLOOKUP(" & "B5" & ",Rates,2,FALSE)),"""",VLOOKUP(" & "B5" & ",Rates,2,FALSE))" ActiveCell.Offset(-1, 1).Select ActiveCell.FormulaR1C1 = "Total" ActiveCell.Offset(1, 0).Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-2]*RC[-1])" Range(ActiveCell.Offset(0, -1), ActiveCell).Select Selection.AutoFill Destination:=Range("ActiveCell.Offset(0, -1):ActiveCell.Offset(" & strLstRw & ", 0)"), Type:=xlFillDefault End Sub Please! Can anyone help me??? I need to finish this project today. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy Formula from one worksheet to another and fill down | Excel Discussion (Misc queries) | |||
Using Data Fill function to copy a Countif formula | Excel Worksheet Functions | |||
Using Data Fill function to copy a Countif formula | Excel Worksheet Functions | |||
Help - copy a formula using the fill handle | Excel Discussion (Misc queries) | |||
The fill feature in Excel that gives option to fill or copy | New Users to Excel |