Excel VBA for dynamic mean weighted ranking

neroed

New Member
Joined
Feb 5, 2018
Messages
1
Hello, I am working on a weighted ranking procedure. I have the procedure written for when it is always rank the top three. The problem is that this needs to be dynamic, it could be any number up to 15 or 20. n is a defined variable and I have a variable called ranknum that identifies how ranks that particular question has. The excel formula would look something like this, =(3*B2+2*C2+D2)/n Any ideas on how to make this dynamic?

Code:
Cells(2, lcol + 3).Activate
    Do While ActiveCell <> ""
       ActiveCell.Offset(0, ranknum + 1).Value = (ActiveCell.Offset(0, ranknum - 2) _
       .Value * 3 + ActiveCell.Offset(0, ranknum - 1).Value _
       * 2 + ActiveCell.Offset(0, ranknum).Value) / n
       ActiveCell.Offset(1, 0).Activate
    Loop
Rank TopicRank1Rank2Rank3Weighted
Topic1
31218
Topic22420
Topic3132
Topic415403
Topic5246
Topic6121416

<tbody>
</tbody>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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
Back
Top