Dear Forum,
I am fairly new to VBA and I have been searching the forum for days now but have not been succceful so far in reaching a solution - so any help is much appreciated.
I am trying to put togheter a macro that will copy information from one row in a worksheet (input data sheet) over to another sheet (contract list).
I need to find the row in the contract list which contains the value in cell d2 on the (input data sheet), based on the input value (which wil vary with all sorts of numbers).
I need the macro to go to the contract list and search colum D for the value that has been input in cell D2 and then search the sheet (contract list) to find the row which contain this value , I then need to copy row 2:2 of the (input sheet) and replace the information that is contained in the row with the matching search on the sheet (contract list).
I tried to record the macro to see if I could alterate it - but I am lost on how to set the criteria ?
This is what it looks like :
Sheets("Input data sheet").Select
Range("D2").Select
Selection.Copy
' here comes the criteria for filetring
Sheets("Contract List").Select
ActiveSheet.ListObjects("List1").Range.AutoFilter Field:=4, Criteria1:= _
"=456789", Operator:=xlAnd
'here the criteria 456789 needs to be variable with what number has been input in cell D2 on the data inout sheet.
Sheets("Input data sheet").Select
Rows("2:2").Select
Selection.Copy
Sheets("Contract List").Select
Rows("3:3").Select
'row 3:3 will vary as the filter will find the row were the information is contained
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.ListObjects("List1").Range.AutoFilter Field:=4
can anyone please help on how I can get the macro to perform this in the middle as the macro is already performing some copying taske before I get to this point????
I am fairly new to VBA and I have been searching the forum for days now but have not been succceful so far in reaching a solution - so any help is much appreciated.
I am trying to put togheter a macro that will copy information from one row in a worksheet (input data sheet) over to another sheet (contract list).
I need to find the row in the contract list which contains the value in cell d2 on the (input data sheet), based on the input value (which wil vary with all sorts of numbers).
I need the macro to go to the contract list and search colum D for the value that has been input in cell D2 and then search the sheet (contract list) to find the row which contain this value , I then need to copy row 2:2 of the (input sheet) and replace the information that is contained in the row with the matching search on the sheet (contract list).
I tried to record the macro to see if I could alterate it - but I am lost on how to set the criteria ?
This is what it looks like :
Sheets("Input data sheet").Select
Range("D2").Select
Selection.Copy
' here comes the criteria for filetring
Sheets("Contract List").Select
ActiveSheet.ListObjects("List1").Range.AutoFilter Field:=4, Criteria1:= _
"=456789", Operator:=xlAnd
'here the criteria 456789 needs to be variable with what number has been input in cell D2 on the data inout sheet.
Sheets("Input data sheet").Select
Rows("2:2").Select
Selection.Copy
Sheets("Contract List").Select
Rows("3:3").Select
'row 3:3 will vary as the filter will find the row were the information is contained
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.ListObjects("List1").Range.AutoFilter Field:=4
can anyone please help on how I can get the macro to perform this in the middle as the macro is already performing some copying taske before I get to this point????