excel - 如何从列中获取最高值的列表?
问题描述
我有一张表,其中前两列有行和列地址,第三列有整数值。
我想从第 1 列和第 2 列中提取最高值及其对应的地址到工作表上的单独列表中。
第三列中可能有多个相等的最高值。我如何将所有这些都放入我的列表中。
我是 Excel VBA 的新手。
解决方案
这可能是一个开始。
Sub maxIntAndOtherStuff()
Dim rng As Range, c As Range, i As Integer, x As Long, y As Long
rw = 1: cl = 3 'Apply starting row & column
Set rng = Range(Cells(rw, cl), Cells(Rows.Count, cl).End(xlUp))
For Each c In rng
If c.Value >= i Then
i = c.Value
End If
Next c
y = 9 'Apply column number for output
x = Cells(Rows.Count, y).End(xlUp).Offset(1).Row 'Finds the first empty row in that column
For Each c In rng
If c = i Then
Cells(x, y).Resize(, 3).Value = c.Offset(, -2).Resize(, 3).Value
x = x + 1
End If
Next c
End Sub
推荐阅读
- arrays - 向数组公式添加多个条件
- haskell - Haskell 中 `putStrLn` 的基本错误。VScode 扩展 Haskelly
- c++ - 检测卡片上的水滴并计算数量及其大小 OpenCV C++
- typescript - TypeScript,类似于Required,但将所有对象属性转换为不可为空
- regex - 1-49 的 6 位数字的正则表达式
- docker - 如何将 Openstack Cinder 卷用作 Kubernetes 持久卷?
- reactjs - React Hooks - 带有钩子的功能组件中 ScrollView 的引用?
- reactjs - React中使用axios删除用户
- javascript - 在 JS 中进行全尺寸跳跃之前,角色会先做一个小跳跃
- r - 将变量的多个值与另一个数据帧的一个值匹配