# KrishnakumarSuper Moderator

• Male
• 46
• from Gurugram/God's own country
• Member since Nov 18th 2004
Posts
4,710
2
Points
14,212
Trophies
2
Profile Hits
8,099
• Hii

i have an excel sheet and iam trying to get the weighted averages for the 4 parameters based on their date, if any one can solve my question it would help to my work. i need macros code for calculating weighted average.

upto now i did the simple average by using below code. can you modify this simple average code to weighted average code

Range("Q" & P + 7) = Round(WorksheetFunction.AverageIf(Range("A8:A" & lastRow_R), CDate(xCol2.Item(P)), Range("E8:E" & lastRow_R)), 2)
Range("R" & P + 7) = Round(WorksheetFunction.AverageIf(Range("A8:A" & lastRow_R), CDate(xCol2.Item(P)), Range("F8:F" & lastRow_R)), 2)
Range("S" & P + 7) = Round(WorksheetFunction.AverageIf(Range("A8:A" & lastRow_R), CDate(xCol2.Item(P)), Range("G8:G" & lastRow_R)), 2)

Here
A Column indicates-Date
E,F&G Column Indicates- Parameters
C Column indicates -Weight for respected item

Q,R,S Column indicates - average results to be shown here

https://www.ozgrid.com/forum/i…post-list/339898-kiran66/