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?
[TABLE="width: 500"]
<tbody>[TR]
[TD]Rank Topic[/TD]
[TD]Rank1[/TD]
[TD]Rank2[/TD]
[TD]Rank3[/TD]
[TD]Weighted[/TD]
[/TR]
[TR]
[TD]Topic1
[/TD]
[TD]3[/TD]
[TD]12[/TD]
[TD]18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic2[/TD]
[TD]24[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic3[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic4[/TD]
[TD]15[/TD]
[TD]40[/TD]
[TD]3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic5[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic6[/TD]
[TD]12[/TD]
[TD]14[/TD]
[TD]16[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
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
<tbody>[TR]
[TD]Rank Topic[/TD]
[TD]Rank1[/TD]
[TD]Rank2[/TD]
[TD]Rank3[/TD]
[TD]Weighted[/TD]
[/TR]
[TR]
[TD]Topic1
[/TD]
[TD]3[/TD]
[TD]12[/TD]
[TD]18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic2[/TD]
[TD]24[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic3[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic4[/TD]
[TD]15[/TD]
[TD]40[/TD]
[TD]3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic5[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Topic6[/TD]
[TD]12[/TD]
[TD]14[/TD]
[TD]16[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]