Need some help finishing off this Macro. The portion of the code in question is below. It checks cell I1 (which subtotals the column), and if it comes up an error, it filtes the rows with the error and changes the vlookup to another file. The problem I have is with the code pasting the new vlookup to the other visible cells. I can see it correctly update the formula on the first visible row, but the copy down part doesnt work. I've tried searching but must not be using the magical words because most every response I find is how to COPY visible cells to another column/workbook etc....not copy a formula only to visible cells.
Note: I also have blank cells below this data so I need to set the range somehow to prevent copying tot he whole sheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Store[/TD]
[TD]Item Code[/TD]
[TD]Description[/TD]
[TD]Bill Qty[/TD]
[TD]Ship Pack[/TD]
[TD]Cost[/TD]
[TD]Cube[/TD]
[TD]Total Cube[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]Misc[/TD]
[TD]2[/TD]
[TD]24[/TD]
[TD]19.8[/TD]
[TD]#N/A[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]Misc[/TD]
[TD]3[/TD]
[TD]12[/TD]
[TD]20.2[/TD]
[TD]#N/A[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Note: I also have blank cells below this data so I need to set the range somehow to prevent copying tot he whole sheet
Code:
If IsError(Range("I1")) = True Then
Range("I2").Select
Selection.AutoFilter
ActiveSheet.Range("$A$2:$N$150000").AutoFilter Field:=9, Criteria1:="#N/A"
Range([H3], Cells(Rows.Count, "H")).SpecialCells(xlCellTypeVisible)(1).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-6],'[Inventory View.xlsx]Sheet1'!C3:C22,20,FALSE)"
Selection.FillDown
ActiveSheet.ShowAllData
End If
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Store[/TD]
[TD]Item Code[/TD]
[TD]Description[/TD]
[TD]Bill Qty[/TD]
[TD]Ship Pack[/TD]
[TD]Cost[/TD]
[TD]Cube[/TD]
[TD]Total Cube[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]Misc[/TD]
[TD]2[/TD]
[TD]24[/TD]
[TD]19.8[/TD]
[TD]#N/A[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]Misc[/TD]
[TD]3[/TD]
[TD]12[/TD]
[TD]20.2[/TD]
[TD]#N/A[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]