Home > Software engineering >  Excel vba to find problems
Excel vba to find problems

Time:11-19

The following code can find the key words in line, how to modify the can find the line and his lines of the following four lines

Sub test ()
Dim Arr, Brr
Dim Srr (1 To 10000, 1 To 12)
Dim D As Object
The Set D=CreateObject (" scripting. The dictionary ")
The Set wb=GetObject (ThisWorkbook Path & amp; "" & amp; "Aaa. XLSX")
With wb. Sheets (the "listing")
Arr=. Range (A3: "L" & amp; . (B3). End (xlDown). Row)
End With
With Sheets (" find ")
Brr=. Range (A2, B2) 'A2, B2 query cell A2: B2
End With
For J=1 To UBound (Brr, 2)
If Brr (1, J) & lt;> "" Then
N=N + 1
D (N)=J
End the If
Next
If N=0 Then
MsgBox "please input conditions
"The Exit Sub
End the If
For I=1 To UBound (Arr)
K=0
For J=1 To N
If Arr (I, D (J)) Like "*" & amp; Brr (, 1 D (J)) & amp; "*" Then K=K + 1
Next
If K=N Then
S=S + 1
For J=1 To UBound (Arr, 2)
Srr (S, J)=Arr (I, J)
Next
End the If
Next
With Sheets (" find ")
Range (" A5: L10000 "). The Clear
If S=0 Then
MsgBox "found out"
The Exit Sub
End the If
. (A5). The Resize (S, 12)=Srr
MsgBox "query" success
End With
End Sub
  •  Tags:  
  • VBA
  • Related