Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 719|回复: 0

两个代码合并一个

[复制链接]
发表于 2023-2-19 17:25 | 显示全部楼层 |阅读模式
Private Sub Worksheet_Change(ByVal Target As Range)
        Dim arr, brr, c As Object, i%, sh5, sh1
        If Target.Row = 18 And Target.Column = 12 Then
    Set c = CreateObject("Scripting.dictionary")
     Set sh5 = Sheets
    Set sh1 = Sheets
    sh1.[a1:c60000].ClearContents
    arr = sh5.[a1].CurrentRegion
            For i = 2 To UBound(arr)
                   If arr(i, 3) = sh1.[l18].Value Then
                        s = arr(i, 1) & arr(i, 3) & arr(i, 2)
                        If Not c.exists(s) Then
                                c(s) = Array(arr(i, 1), arr(i, 2), arr(i, 3))
                        Else
                                c(s) = Array(arr(i, 1), c(s)(1) + arr(i, 2), arr(i, 3))
                        End If
                    End If
                Next i
        IM = c.items

  sh1.[a2].Resize(c.Count, 3) = Application.Transpose(Application.Transpose(IM))


End If

End Sub



     Private Sub Worksheet_Change(ByVal Target As Range)    2代码
Range("m16").Select
If ActiveCell.Value > 50000 Then
Macro2
End If
Range("m16").Select
If ActiveCell.Value < 500 Then
Macro1
End If
End Sub


您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-4 01:38 , Processed in 0.247288 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表