Re: Find a Cell on one sheet, write data into another sheet
Hi,
Try the following code.
Place the cursor where "yes" is there in your Search sheet and then run this macro. Before running this macro please ensure the following:
Let your Target sheet be Sheet2(if not change the sheet reference). The code start placing the data in Target sheet from Cell A2 on wards, you can change this to your requirements.
[vba]
Sub Cond_Copy()
Application.ScreenUpdating = False
ReturnSheet = ActiveSheet.Name
Set AreaRange = ActiveCell.CurrentRegion
Set MyRange = Intersect(ActiveCell.EntireColumn, AreaRange)
' Define area that matches selected cell value
x = ActiveCell.Value
For Each Cell In MyRange
If Cell.Value = x Then
If i = 0 Then
Set NewRange = Cell.EntireRow
Else
Set NewRange = Union(NewRange, Cell.EntireRow)
End If
i = i + 1
End If
Next
Set NewRange = Intersect(NewRange, AreaRange)
' Copy & Paste
Sheets(2).Select
Cells.ClearContents
Range("A2").Select
NewRange.Copy
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1").Select
Sheets(ReturnSheet).Select
Application.ScreenUpdating = True
MsgBox ("See Sheet2")
Sheets(2).Select
End Sub
[/vba]
This code I have taken from xl-logic.com. Post back if you have any problems.
HTH.