如何获取数组中具有最高值的变量的名称

How to get the name of the variable with the highest value in an array

所以我有以下公式

Dim A as integer    
Dim B as integer
Dim C as integer
Dim D as integer
Dim E as integer
Dim F as integer

A=1
B=2
C=3
D=4
E=5
F=6

MaxValue = Application.Max(A,B,C,D,E,F)

我需要获取值最高的变量的名称 (F)

我要获取变量 MaxValue 中的最大值,因此 MaxValue 将等于 6。但是如何获取变量的值?

意思是,我怎样才能得到"F"?

谢谢

同意@BruceWayne 的观点,这听起来像是一个 XY 问题,但是:

Dim arrNames, arrVals, m

arrNames = Array("A", "B", "C")
arrVals = Array(1, 3, 2)

m = Application.Match(Application.Max(arrVals), arrVals, 0)

Debug.Print arrNames(m - 1) 'm is 1-based

您似乎没有像问题中那样对实际值进行硬编码(如果是这种情况,您在 运行 代码之前就知道答案...)但您得到了值来自其他地方,因此解释您的实际任务是什么会很有用。