标签:ext row for 定义 function -- 范围 输出 vba
Sub shishi() Range("e2") = Split(Range("e1"), "-")(0) ‘用短横线分隔后取第1个值 End Sub ---------------- Sub shishi() Dim arr(1 To 5) ‘声明数组 For i = 1 To 5 arr(i) = Range("b" & i + 1) * Range("c" & i + 1) Next Range("h3") = Application.WorksheetFunction.Max(arr) Range("h2") = Range("a" & Application.WorksheetFunction.Match(Range("h3"), arr, 0) + 1) ‘0代表精确匹配到最大值对应的产品种类 End Sub --- 数据为多行时 Sub shishi() Dim arr() ‘这里必须写范围,如果不写,则在下方必须要定义 Dim j, i As Integer j = Range("a65536").End(xlUp).Row - 1 ReDim arr(1 To j) For i = 1 To j arr(i) = Range("b" & i + 1) * Range("c" & i + 1) Next Range("h3") = Application.WorksheetFunction.Max(arr) Range("h2") = Range("a" & Application.WorksheetFunction.Match(Range("h3"), arr, 0) + 1) ‘0代表精确匹配 End Sub ----- Sub shishi() Dim arr() arr = Range("a:i") ‘输出第三行,第九列 MsgBox arr(3, 9) End Sub
标签:ext row for 定义 function -- 范围 输出 vba
原文地址:https://www.cnblogs.com/pingzizhuanshu/p/11219713.html