列索引号

时间:2016-04-16 02:23:39

标签: excel

有人可以帮助我使用索引编号而不是字母范围吗?

见下面的代码:

Function Integer
    Dim value As Integer

1 个答案:

答案 0 :(得分:3)

您不需要循环:)

这是你想要的吗?

Sub Sample()
    Dim Rng As Range

    Set Rng = Columns(2)

    '~~> This will give you the row number of the max value
    '~~> =MATCH(MAX(B:B),B:B,0)
    MsgBox Evaluate("MATCH(MAX(" & Rng.Address & ")," & Rng.Address & ",0)")

    '~~> OR
    MyVariable = Evaluate("MATCH(MAX(" & Rng.Address & ")," & Rng.Address & ",0)")
    MsgBox MyVariable 
End Sub