Excel VBA在特定工作表上找到范围内的最大值 [英] Excel VBA find maximum value in range on specific sheet

查看:649
本文介绍了Excel VBA在特定工作表上找到范围内的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现以下代码正在获得范围内的最大值:

I found that the following code is getting max value in range:

Cells(Count, 4)=Application.WorksheetFunction.Max(Range(Cells(m, 1),Cells(n, 1)))

如何在特定工作表中进行搜索?在这种情况下Data工作表

How can I search within a specific sheet? Data sheet in this case

赞:

Worksheets(d).Cells(x, 4).Value = Worksheets("Data")... ????? FIND MAX ????

推荐答案

这通常可以工作,但是缺少参考:

This will often work, but is missing a reference:

 worksheets("Data").Cells(Count, 4)=  Application.WorksheetFunction.Max _
    ( worksheets("Data").range( cells(m,1) ,cells(n,1) )

在单元格"文本之前应先引用该单元格所在的工作表,我会这样写:

The text "cells" should be preceded by a reference to which worksheet the cells are on, I would write this:

worksheets("Data").Cells(Count, 4) = Application.WorksheetFunction.Max _
    ( worksheets("Data").range( worksheets("Data").cells(m,1) ,worksheets("Data").cells(n,1) )

这也可以这样写,更清楚:

This can also be written like this which is clearer:

with worksheets("Data")
    .Cells(Count, 4) =  Application.WorksheetFunction.Max _
                            ( .range( .cells(m,1) ,.cells(n,1) )
End With 

我希望这会有所帮助.

哈维

这篇关于Excel VBA在特定工作表上找到范围内的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆