跪求大佬帮忙指点下,根据C列相同编号C的商品,按K列数值比较,把大数值的B列粘在L列上

360U2785635172 |浏览730次
收藏|2020/05/18 07:12

满意回答

2020/05/18 07:23

用VBA可以轻松实现,把下面程序复制到你当前工作表的VBA代码页下即可。使用方法:当你选择了C列第2行以下时,从C2开始自动检索C列,直到C列的内容为空时止。并把 你所选的相同编号的最大值显示在你所选择行的L列下面。Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim I As Long, J As Long Dim N As Long Dim S As String, S2 As String If Target.Count = 1 And Target.Column = 3 And Target.Row > 1 Then Range("K:K").ClearContents Range("K1").Value = "调出门店" I = 2 S = Target.Value N = -2147483648# Do If Len(Cells(I, 3)) = 0 Then Exit Do If Cells(I, 3).Value = S Then If Cells(I, 10) > N Then S2 = Cells(I, 2) & "," N = Cells(I, 10) ElseIf Cells(I, 10) = N Then S2 = S2 & Cells(I, 2) & "," End If End If I = I + 1 Loop I = Target.Row Do J = InStr(S2, ",") If J = 0 Then Exit Do Cells(I, 11) = Left(S2, J - 1) S2 = Mid(S2, J + 1) I = I + 1 Loop End IfEnd Sub

李晃资_2013

其他回答(0)
0人关注该问题
+1

 加载中...