trying match a cell value to another sheet within the workbook (sheet1 cell A1) like a Vlookup but when it matches in the a column of Sheet 3 i want it to copy the row and paste it in A5 on sheet1.
here is what i'm using right now....
Sub copyit()
Dim MyRange, MyRange1 As Range
Sheets("Sheet2").Select 'Change to suit
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets("Sheet2").Range("A1:A" & lastrow)
For Each c In MyRange
If c.Value = "Sheet1!A1" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Copy
End If
Sheets("Sheet1").Select 'Change to where you want it
Range("A5").Select 'Change to where you want it
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
here is what i'm using right now....
Sub copyit()
Dim MyRange, MyRange1 As Range
Sheets("Sheet2").Select 'Change to suit
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets("Sheet2").Range("A1:A" & lastrow)
For Each c In MyRange
If c.Value = "Sheet1!A1" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Copy
End If
Sheets("Sheet1").Select 'Change to where you want it
Range("A5").Select 'Change to where you want it
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub