hey Cguan,
thank you for the reply. the macro works but copies the entire row to sheet2.
nearly there but not quite. two more things
1) if i need to look for a whole column instead of y2 = "0014" for example y2 = A:A in sheet 2
2)I need to copy the value in Sheet1 Column C only not the entire row.
thanks
try this, hope it helps.
Sub Macro1()
Dim x, y As Boolean
Dim x1, x2, x3 As String
Dim y1, y2 As String
Dim z1, z2 As String
'declare the data to find
'y1 = "700"
'y2 = "0014"
y1 = InputBox("Enter data to search in sheet 1 column a")
y2 = InputBox("Enter data to search in sheet 2 column a")
'activate sheet1 and search
Sheets("Sheet1").Select
Columns("b:b").Select
x = Selection.Find(What:=y1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'check if data found then copy
If x = True Then
x1 = ActiveCell.Row
x3 = ActiveCell.Value
'Rows(x1).Select
z1 = Cells(x1, 3).Select
Selection.Copy
End If
'select sheet2 and search the data
Sheets("Sheet2").Select
Columns("a:a").Select
y = Selection.Find(What:=y2, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'found then paste the data from sheet1
If y = True Then
x1 = ActiveCell.Row
Cells(x1, 2).Select
Selection.PasteSpecial
End If
End Sub
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
Offline 1,317 posts
since Apr 2007