Hi All
I made a recorded macro, so if any one can help to put the recorded macro in an elegant vba way some modifcations to be made still to end of last row for both imput sheet column A and B as COLUMN C and D may have data of 1500 to 3500 rows to fill columns A and B of imput sheet.
For Product database same lookup from A,B,C.D to last row. (product database can read up to 30000 rows)
recorded macro has been for short range.as below
Formula not to appear in cells.
As below sample of sheet + formula
and recorded macro
I made a recorded macro, so if any one can help to put the recorded macro in an elegant vba way some modifcations to be made still to end of last row for both imput sheet column A and B as COLUMN C and D may have data of 1500 to 3500 rows to fill columns A and B of imput sheet.
For Product database same lookup from A,B,C.D to last row. (product database can read up to 30000 rows)
recorded macro has been for short range.as below
Formula not to appear in cells.
As below sample of sheet + formula
and recorded macro
Imput sheet
[TABLE="width: 1648"]
<colgroup><col span="2"><col><col></colgroup><tbody>[TR]
[TD]Coding Reference
[/TD]
[TD]Coding Description[/TD]
[TD]Product Code [/TD]
[TD]Product Description[/TD]
[/TR]
[TR]
[TD] =IFERROR(INDEX('Product Database '!$A:$D,MATCH('Imput Datasheet'!C2,'Product Database '!C:C,0),1),"")[/TD]
[TD] =IFERROR(INDEX('Product Database '!$A:$D,MATCH('Imput Datasheet'!C2,'Product Database '!C:C,0),2),"")[/TD]
[TD]0062531[/TD]
[TD]BAC 30L NOIR[/TD]
[/TR]
</tbody>[/TABLE]
Product database
[TABLE="width: 775"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]Coding Reference
[/TD]
[TD]Coding Description[/TD]
[TD]Product Code [/TD]
[TD]Product Description[/TD]
[/TR]
[TR]
[TD]83119000[/TD]
[TD]WELDING ELECTRODES[/TD]
[TD]0046371[/TD]
[TD]POUR ASSEMBLAGE TRAVAUX COURANTS (ZINGUERIE, FERBLANTERIE) -[/TD]
[/TR]
</tbody>[/TABLE]
Sub INDEXMATCHIFERROETEST()
'
' INDEXMATCHIFERROETEST Macro
'
'
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(INDEX('Product Database '!C1:C4,MATCH('Imput Datasheet'!RC[2],'Product Database '!C[2],0),1),"""")"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:B2"), Type:=xlFillDefault ***(this need to modify to last row of data)***
Range("A2:B2").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(INDEX('Product Database '!C1:C4,MATCH('Imput Datasheet'!RC[1],'Product Database '!C[2],0),2),"""")"
Range("A2:B2").Select
Selection.AutoFill Destination:=Range("A2:B32")
Range("A2:B32").Select
Columns("A:A").ColumnWidth = 19.29
Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(INDEX('Product Database '!C1:C4,MATCH('Imput Datasheet'!RC[1],'Product Database '!C[1],0),2),"""")"
Range("A2:B2").Select
Selection.AutoFill Destination:=Range("A2:B32")
Range("A2:B32").Select
Columns("B:B").EntireColumn.AutoFit
Selection.AutoFill Destination:=Range("A2:B35"), Type:=xlFillDefault***(this need to modify to last row of data)***
Range("A2:B35").Select
End Sub
Last edited: