EXCEL VBA How to achieve multiple objectives content search list, and mark the line number, column number?

 

A group where there is a VBA friends for help, I wrote a try, if you could. . . Later in improvements

 

 

 

Sub test_find1()


Dim sh1 As Object
Dim cell1 As Object
Dim arr1()

target1 = "A"
I = 1

For Each sh1 In ThisWorkbook.Worksheets
    ReDim Preserve arr1(1 To I)
    arr1(I) = sh1.Name
    I = I + 1
Next


Debug.Print "符合查找目标" & target1 & "的单元格有如下这些:"
For Each I In arr1
     For Each cell1 In Sheets(I).UsedRange    '有中文sheet名好像会报错,现在还没查原因
        If cell1.Value = target1 Then
           Debug.Print I & ".cells(" & cell1.Row & "," & cell1.Column & ")"
        End If
    Next
Next

End Sub

 

 

 

Published 383 original articles · won praise 45 · Views 100,000 +

Guess you like

Origin blog.csdn.net/xuemanqianshan/article/details/104040300