fari1
Active Member
- Joined
- May 29, 2011
- Messages
- 362
hi, my below code finds the text "consolidated" and in sheet3 list all the cells that contain consolidated. i want this code to copy the whole instead of that cell which contains consolidated and gives the output in sheet3.e.g
with reference to the above example i want to get the complete row copied as a result of this code in sheet3.the code is below
HTML:
A B C D E
Consolidated sheets result
with reference to the above example i want to get the complete row copied as a result of this code in sheet3.the code is below
Code:
Sub findTEXT()
Dim f As Range, fa As String, i As Long
Dim src As Worksheet, dst As Worksheet
Set src = Sheets("sheet2") 'sheet to be searched, change as required
Set dst = Sheets("sheet3") 'sheet for output, change as required
i = 1
With dst
Set f = src.Cells.Find(What:="CONSOLIDATED", After:=src.Cells(1), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not f Is Nothing Then
fa = f.Address
Do
If Len(f.Value) < 50 Then
.Range("A" & Rows.Count).End(xlUp)(2) = f.Value
.Range("B" & Rows.Count).End(xlUp)(2) = src.Range("A1").Value
i = i + 1
End If
Set f = src.Cells.FindNext(f)
Loop Until fa = f.Address
End If
End With
End Sub