mantooth29
New Member
I am looking to write a macro that will copy a row of cells in Sheet 2 (Database) if the value in column B of 'Database' matches A1 in 'Sheet1'.
I have compiled the following incomplete macro:
Sub Stock()
Set i = Sheets("Sheet1").Range("A1")
Set e = Sheets("Database").Range(B)
Set f = Sheets("Database").EntireRow
If i.Range("E1") = e.Range("B") Then
Set NewRange = ?????????????
Range("NewRange").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Range("NewRange").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I think I am on the right track, but need help defining NewRange which is the entire row in 'Database' where the value in column B and Sheet1!A1 are identical.
Any suggestions?
I have compiled the following incomplete macro:
Sub Stock()
Set i = Sheets("Sheet1").Range("A1")
Set e = Sheets("Database").Range(B)
Set f = Sheets("Database").EntireRow
If i.Range("E1") = e.Range("B") Then
Set NewRange = ?????????????
Range("NewRange").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Range("NewRange").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I think I am on the right track, but need help defining NewRange which is the entire row in 'Database' where the value in column B and Sheet1!A1 are identical.
Any suggestions?