I have a code to find out for a particular text in all the worksheets of a workbook and if a text is there in a particular worksheet, the name of that worksheet will be be copies to a cell in Sheet1. Following is the code
But the excel is crashing when i run this code. Could you please help me out??
Code:
Sub searchname_Click()
Dim ThisAddress$, Found, FirstAddress
Dim Lost$, N&, NextSheet&
Dim CurrentArea As Range, SelectedRegion As Range
Dim Reply As VbMsgBoxResult
Dim FirstSheet As Worksheet
Dim Ws As Worksheet
Dim Wks As Worksheet
Dim Sht As Worksheet
Set FirstSheet = ActiveSheet '< bookmark start sheet
Lost = InputBox(prompt:="Type in the details you are looking for!", _
Title:=" Find what?", Default:="*")
If Lost = Empty Then End
For Each Ws In Worksheets
Ws.Select
With ActiveSheet.Cells
Set FirstAddress = .Find(What:=Lost, LookIn:=xlValues)
If FirstAddress Is Nothing Then '< blank sheet
Next Ws
End If
FirstAddress.Select
With Selection
Set Found = .Find(What:=Lost, LookIn:=xlValues)
If Not Found Is Nothing Then
FirstAddress = Found.Address
End If
End With
Selection.Copy
Worksheets("Sheet1").Range("a65536").End(xlUp).Offset(1, 0).Value = ActiveSheet.Name
Next Ws
FirstSheet.Select
End Sub
But the excel is crashing when i run this code. Could you please help me out??