weighted average VBA Code

kiran66

New Member
Joined
Dec 8, 2020
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
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
 

Attachments

  • Capture11.JPG
    Capture11.JPG
    58.5 KB · Views: 7

kiran66

New Member
Joined
Dec 8, 2020
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
Hii,

can i get the same code in the module 3 line number 53 we are getting average for the total number of quantities here also we need weighted average
present i am getting the average values of P,Q,R,S,T columns of individual sheet in performance sheet D,E,F,G,H by using module 3 code , but i need weighted average here also based on the start date and end date
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,551
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
When you get weighted average at module 1, module 3 only copy that weighted averages to worksheet(2).
 

Watch MrExcel Video

Forum statistics

Threads
1,126,896
Messages
5,621,497
Members
415,844
Latest member
Reda Fouad Ramzy

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
Top