B
Bishop
Here's my code snippet:
NewRow2 = 6
For RowCount = Start To NewRow
If NewRow2 < NewRow Then
.Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),11,FALSE)),""""," & _
"VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),11,FALSE))"
.Range("AA" & NewRow2 & ":AA" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),6,FALSE)),""""," & _
"VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),6,FALSE))"
.Range("Z" & NewRow2 & ":AA" & (NewRow2 + 4)).FillDown
NewRow2 = NewRow2 + 8
End If
Next RowCount
The first run through this code puts the formulas in Z6 and AA6 and fills
down to Z10 and AA10. Which is what I want. After "NewRow2 = NewRow2 + 8"
NewRow2 is now 14. Again, this is correct. The problem is I have $A6 in my
VLOOKUP formula so, on the second pass, the formulas are place in Z14 and
AA14, as they should, but my VLOOKUP formula still has $A6 and I need it to
have $A14. How do I make that change like it does in my .Range?
NewRow2 = 6
For RowCount = Start To NewRow
If NewRow2 < NewRow Then
.Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),11,FALSE)),""""," & _
"VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),11,FALSE))"
.Range("AA" & NewRow2 & ":AA" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),6,FALSE)),""""," & _
"VLOOKUP($A6,INDIRECT(""'[""&$Y$2&""]By_Rep_by_Filter'!$F$1:$P$5000""),6,FALSE))"
.Range("Z" & NewRow2 & ":AA" & (NewRow2 + 4)).FillDown
NewRow2 = NewRow2 + 8
End If
Next RowCount
The first run through this code puts the formulas in Z6 and AA6 and fills
down to Z10 and AA10. Which is what I want. After "NewRow2 = NewRow2 + 8"
NewRow2 is now 14. Again, this is correct. The problem is I have $A6 in my
VLOOKUP formula so, on the second pass, the formulas are place in Z14 and
AA14, as they should, but my VLOOKUP formula still has $A6 and I need it to
have $A14. How do I make that change like it does in my .Range?