EXCEL VBA:在列中找到最小值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28743642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 06:21:55  来源:igfitidea点击:

EXCEL VBA: finding lowest value in column

excelvbaexcel-vbamin

提问by Macb3th

i have tried to make select to pick column and find lowest value, but i dont know whats wrong:

我试图选择选择列并找到最低值,但我不知道出了什么问题:

mazas = Application.WorksheetFunction.Min(Sheets("maping").Range(Range("C3"), Range("C3").End(xlDown)).Select)

I think the biggest problem is that i dont know lenght of column it can gave 3 number or 3000 numbers, but it will always start at C3. Any ideas how to make it work?

我认为最大的问题是我不知道它可以给出 3 个或 3000 个数字的列的长度,但它总是从 C3 开始。任何想法如何使它工作?

回答by Gary's Student

You don't need to worry about where the data ends, just skip the first two rows:

您无需担心数据在哪里结束,只需跳过前两行:

Sub NotTheFirstTwoRows()
    Dim c As Range
    Set c = Range("C3:C" & Rows.Count)
    MsgBox Application.WorksheetFunction.Min(c)
End Sub

Because any blanks at the bottom of the column will be ignored.

因为列底部的任何空白都将被忽略。