Let's say, you buy and sell second-hand cars. So your recent purchase is as follows: you bought 8 Toyota cars each $3500 and so on.
So the average price of cars = (4600 + 3500 + 5000 + 4200)/4 = 4325 dollar
But you want to get more accurate representation of the average price, so you want to calculate weighted average.

In Excel you can do it by the SUMPRODUCT and SUM functions
=SUMPRODUCT(B2:B5, C2:C5) / SUM(C2:C5)
So the average price you paid per car is 4123.81 Dollar (weighted average).
How it works?
The SUMPRODUCT function is used to multiply each of the car price by its quantity (or weight), and then the total sum of it.
The SUM function is used to add up the quantities (or weights) and then the total sum of it.
Finally you divide the result of SUMPRODUCT by the SUM to get your weighted average.
In simple mathematics, you can do it as follows:
weighted average = ((4600.00 * 6) + (3500.00 * 8 ) + (5000.00 * 2) + (4200.00 * 5)) / (6 + 8 + 2 + 5) = 4123.81
So that's it.