PDA

View Full Version : [SOLVED] VBA code for sum function for filtered columns



Veeru
02-28-2018, 03:03 AM
Hi,

I have one code which can find last row and apply sum function.

Im looking something which willl do for filtered valus as well.

sorry i am not sure how to paste code here.....

Thanks

mancubus
02-28-2018, 04:42 AM
sorry i am not sure how to paste code here.....


see #1 in may signature.

Veeru
02-28-2018, 05:03 AM
Sorry still not find....# 1 is not working

Paul_Hossler
02-28-2018, 06:38 AM
Sorry still not find....# 1 is not working

21716

Veeru
02-28-2018, 08:56 PM
Do i need to paste code in between code/code...no sure but I am attaching a excel with code in it...
hope that will help. thanks

mancubus
02-28-2018, 11:37 PM
Sub addtwo()

Dim LastRow As Long

With Sheets("FY-2017")
LastRow = .Cells(.Rows.Count, 6).End(xlUp).Row
.Range("J1").Formula = "=Aggregate(9,7,F2:F" & LastRow & ")"
End With

End Sub


what is wrong with the Aggregate function?



if you want to display the formula result rather then the formula in a cell, you can use Evaluate method



.Range("J1").Value = Evaluate("=Aggregate(9,7,F2:F" & LastRow & ")")

Veeru
03-01-2018, 12:21 AM
Thanks Mancubus...it is working fine now.....apprecaite your time

mancubus
03-01-2018, 01:08 AM
you are are welcome

mark the thread as solved (my signature, #3) for future references to the thread pls.