Need Help in Auto fill - would Vlookup be better or Macro

Excelnoob01

New Member
Joined
Sep 7, 2015
Messages
1
I have a data sheet where i need data from sheet 1 column H to look up for data on sheet 2 in coloumn C and find the matching value and fill the data from rows adjcent to Column C into Sheet 1, Column J and K

Basically its should be like the below concept

Sheet 1


REFDOBQuantityPckgTotalDiscountNet AmountCodeNameCompDistrySign
X1116 jul 201524999980998CON111874

<tbody>
</tbody>


Sheet 2

NameCompanyCodeDate
CharlesDuckling IncCON111

<tbody>
</tbody>


How can i have a formula or code that can auto fill this into sheet one once i put it under the code column ?
I want Charles and Duckling to be filled up automatically into Sheet 1
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
A VLookup would work but only if the Code column in the second sheet was the first column (ie your fields were Code, Name, Company, Date). VLookup can only look forwards from the lookup column, not backwards.

If you don't want to re-arrange the sheet 2 data you can use the following formula:


=IFERROR( INDIRECT("Sheet2!R" & MATCH(H2, Sheet2!C:C ,0) & "C1" ,FALSE),"")


You will have to modify it so that "Sheet2!R" shown in red refers to your sheet 2 name but with !R appended to the end.

The range shown in green (H2) will be the reference to the Code column in sheet 1.

The range shown in blue Sheet2!C:C can be changed to refer to whatever the range is for the Code values on sheet 2.

Reference to "C1" will return the value in the first column in sheet 2 (Name) and can be changed to the Company name by using "C2" to refer to column 2.

The formula can be copied or autofilled down the data as needed.
 
Upvote 0

Forum statistics

Threads
1,216,074
Messages
6,128,649
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top