Fill down with visible cells not working right

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hey guys,

so i apply filters before the following code, but this code isnt working right. I just need it to apply to visible cells only and it just says calculating and only puts in in as2 which it shouldnt because thats filtered out. The rest of the rows are simply blank. When i remove all fiters and try the code it works for all 6000 lines but thats not what im wanting.

Range("as2").Formula = "=CONCATENATE(RC[-40],RC[-39])"

Range("as2:as6000").SpecialCells(xlCellTypeVisible).FillDown

Range("at2").Formula = "=SUMIF(C[-1],RC[-1],C[-9])"

Range("at2:at6000").SpecialCells(xlCellTypeVisible).FillDown

Range("aw2").Formula = "=CONCATENATE(RC[-4],RC[-3])"

Range("aw2:aw6000").SpecialCells(xlCellTypeVisible).FillDown

Any ideas is greatly appreciated!

Jordan
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
What happens if you apply the formula directly?

VBA Code:
Range("as2:as6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=CONCATENATE(RC[-40],RC[-39])"
Range("at2:at6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=SUMIF(C[-1],RC[-1],C[-9])"
Range("aw2:aw6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=CONCATENATE(RC[-4],RC[-3])"
 
Upvote 0
What happens if you apply the formula directly?

VBA Code:
Range("as2:as6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=CONCATENATE(RC[-40],RC[-39])"
Range("at2:at6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=SUMIF(C[-1],RC[-1],C[-9])"
Range("aw2:aw6000").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=CONCATENATE(RC[-4],RC[-3])"
works great thanks! why didnt mine work vs yours that works?

Jordan
 
Upvote 0
It is applying the formula directly to the cells and not filling down so it is a bit like the VBA equivalent of manually typing a formula in a cell rather verses manually dragging a formula down.

You could use a normal formula rather than an R1C1 formula and it would do the same for instance
VBA Code:
Range("at2:at6000").SpecialCells(xlCellTypeVisible).Formula = "=SUMIF(AS:AS,AS2,AK:AK)"
Excel is intelligent enough to adjust for the different rows.
 
Upvote 0
You could use a normal formula rather than an R1C1 formula and it would do the same for instance
VBA Code:
Range("at2:at6000").SpecialCells(xlCellTypeVisible).Formula = "=SUMIF(AS:AS,AS2,AK:AK)"
Mark, I think you will find that alternative does not work unless row 2 happens to be visible?
 
Upvote 0
@Peter_SSs I was assuming wrongly that row 2 was visible because that was the row being filled down from, after re-reading I see that is incorrect.

Thanks for pointing it out.
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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