Option Explicit
Const strText As String = "school"
Sub ColSearch_DelRows()
Dim rng1 As Range
Dim cel As Range
Dim strFirstAddress As String
Dim lAppCalc As Long
Dim strTmp As String
'Get working range from user
On Error Resume Next
Set rng1 = Application.InputBox("Please select range to search for " & strText, "User range selection", Selection.Address(0, 0), , , , , 8)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
With Application
lAppCalc = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set cel = rng1.Find(strText, rng1.Cells(rng1.Cells.Count), xlValues, xlPart, xlByRows, xlNext, False)
If Not cel Is Nothing Then
strFirstAddress = cel.Address
strTmp = cel.Value
Do
Set cel = rng1.FindNext(cel)
If strFirstAddress <> cel.Address Then strTmp = strTmp & vbCrLf & cel.Value
Loop While strFirstAddress <> cel.Address
End If
With Application
.ScreenUpdating = True
.Calculation = lAppCalc
End With
MsgBox strTmp
[c1].Value = strTmp
End Sub
|