|
楼主 |
发表于 2024-10-2 21:10
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST2()
Dim r&, wks As Worksheet, strFind$, rng As Range, rngFind As Range
Application.ScreenUpdating = False
With Worksheets(1)
strFind = .[a1].Value
.Range("A3:H" & .Rows.Count).Clear
For Each wks In Worksheets
If wks.Name <> .Name Then
Set rng = wks.[a1].CurrentRegion
Set rngFind = rng.Find(strFind, , , xlWhole)
If Not rngFind Is Nothing Then
r = .Cells(.Rows.Count, "G").End(xlUp).Row
r = IIf(r = 1, 3, r + 2)
.Cells(r, 1).Value = wks.Name
rng.Copy .Cells(r, 2)
End If
End If
Next
.Activate
End With
Application.ScreenUpdating = True
Beep
End Sub
我看到的代码不一样啊 |
|