|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
改一下, 改為能多格同時處理Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rng As Range, s$(2), ar
- Set rng = Application.Intersect(Range("i2:i" & [h65536].End(3).Row), Target)
- If rng Is Nothing Then Exit Sub
- Application.EnableEvents = 0
- ar = Sheets(1).[a1].CurrentRegion.Resize(, 3).Offset(1, 1).Value
- For Each c In rng.Cells
- s(0) = c.Value: s(2) = c.Address
- For i = 1 To UBound(ar)
- If UCase(s(0)) = ar(i, 1) Then Exit For
- Next
- If Not i > UBound(ar) Then s(0) = ar(i, 2): s(1) = ar(i, 3)
- c.Resize(1, 2) = Application.Transpose(Application.Transpose(s))
- Next
- Application.EnableEvents = 1
- End Sub
复制代码 |
|