PDA

View Full Version : Solved: Filling certain Cells



Klartigue
04-19-2012, 08:43 AM
I know you all answered a previous question for me about autofilling select cells..but i have a variation of that question.

Please see the attached document.

Notice in column G, there are cusips and some of them are the same. In column AN, there are quantites. So in column AC, i would like to sum the block quantity for each cusip.

So for example, for cusip 145681TR3, i would like to sum AN9+AN10+AN11.

And do this for each cusip.


You all gave me the formual =IF(A4"Block",Q3,R4) for a similar question..

Could I turn this into saying =IF(G9 = "value in G9," then sum ANs and place in AC???

Bob Phillips
04-19-2012, 03:49 PM
Do you mean

=SUMIF(G:G,G9,AN:AN)

Klartigue
04-20-2012, 07:52 AM
Yes that works great, thanks!

Klartigue
04-20-2012, 08:01 AM
Heres the code that works:

Sub Quantities()
Dim lastrow As Long
Dim i As Long
With ActiveSheet

lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 9 To lastrow
With .Cells(i, "AC").Select
ActiveCell.FormulaR1C1 = "=SUMIF(C[-22],RC[-22],C[11])"

End With

Next i
End With
End Sub

Thanks for the help!