vba to copy names to each product type

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I have a sheet that has product numbers is column A and dates in column J
now i E and F i have make and model however over the years these have become incorrect,
so what i need is a macro that can do this,
first sort by column A and Column J (both ascending)
then for each product number in column A find the latest date in column J copy whats in E and F and paste it into all rows with the same product number.
so simply put, for each product number in column A whatever the data in E and F of the row with the newest date in column J that data should be for all rows with that product number.

hope thats clear, please help if you can i totally stuck
Thanks
Tony
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Perhaps try using a formula to create a new table with the values you want - usually simpler and safer than a macro.

If the table name is "tblData" with headings of the columns: Product, ColumnE, ColumnF, and it is sorted Descending by Product and Date then the formula =XLOOKUP(tblData[@Product],tblData[Product],tblData[[ColumnE]:[ColumnF]],0,1) will give you the values you want. Place the formula on the same row and to the right of the table.

MrExcel.xlsx
ABCDEFGHIJKLM
1ProductBCDColumnEColumnFGHIDateCorrect ECorrect F
2A123GoodBetter4/6/2004GoodBetter
3A123SDFGHJ4/6/2002GoodBetter
4A123ERTFGH4/6/1990GoodBetter
5A123EFGDFG4/6/1989GoodBetter
6A123ABCDEF4/6/1988GoodBetter
7A444AnotherOK4/6/2009AnotherOK
8A444SDFGHJ4/6/2002AnotherOK
9A444ERTFGH4/6/1990AnotherOK
10A444EFGDFG4/6/1989AnotherOK
11A444ABCDEF4/6/1988AnotherOK
Sheet1
Cell Formulas
RangeFormula
L2:M11L2=XLOOKUP(tblData[@Product],tblData[Product],tblData[[ColumnE]:[ColumnF]],0,1)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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