从值范围中查找最小值和最大值

时间:2016-05-05 11:45:06

标签: vba range max minimum

我有以下数据的擅长 -

Value   Date    Time
0   1-May-16    11:20 AM
0   1-May-16    12:05 PM
0   1-May-16    11:30 AM
0   5-May-16    3:40 PM
1   3-May-16    1:00 AM
1   2-May-16    1:45 AM
0   1-May-16    6:04 AM
0   4-May-16    7:09 AM
0   5-May-16    8:20 PM
2   5-May-16    1:53 AM
2   1-May-16    2:54 AM
3   1-May-16    7:35 PM
3   4-May-16    8:34 AM
4   5-May-16    2:12 PM
0   2-May-16    12:11 PM
5   1-May-16    12:45 PM
5   3-May-16    4:55 AM
5   3-May-16    1:12 AM

我需要按值列汇总我的数据,每个值的最小和最大日期和时间。

上述数据的输出应如下所示 -

    Min     Max 
    Date    Time    Date    Time
0   1-May-16    11:20 AM    5-May-16    3:40 PM
1   2-May-16    1:45 AM 3-May-16    1:00 AM
2   1-May-16    2:54 AM 5-May-16    1:53 AM
3   1-May-16    7:35 PM 4-May-16    8:34 AM
4   5-May-16    2:12 PM 5-May-16    2:12 PM
5   3-May-16    1:12 AM 3-May-16    4:55 AM

请帮忙

1 个答案:

答案 0 :(得分:1)

试试这个:

Set range from which to determine smallest value
Set rng = Sheet1.Range("A1:Z100")

'Worksheet function MIN returns the smallest value in a range 
dblMin = Application.WorksheetFunction.Min(rng)

自:

http://www.globaliconnect.com/excel/index.php?option=com_content&view=article&id=105:find-smallest-and-largest-value-in-range-with-vba-excel&catid=79&Itemid=475