How to populate a cell basing on criteria

Patrickboy

New Member
Joined
Aug 4, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a list of two column A-B I need to check names on column B and if two or more names are same, I need to copy the value of A cell if is "not found".

In this example cell A1 and cell A11 should takes the value of cell A10 because B10 and B1 and B11 are same name. If it's not found, should not take anything.

How to do?

thanks a lot


aum.xlsx
AB
1Not foundNAME1
2Not foundNAME2
3Example1NAME3
4Not foundNAME4
5Not foundNAME5
6Not foundNAME6
7Example1Name3
8Not foundNAME8
9Not foundNAME9
10Example2NAME1
11Not foundNAME1
Foglio13
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Assuming column J is available as a helper (any other columns would do too), you could try this with a copy of your workbook.

VBA Code:
Sub rename()
  Dim lr As Long
  
  lr = Range("A" & Rows.Count).End(xlUp).Row
  With Range("J1:J" & lr)
    .Formula = Replace("=INDEX(FILTER(A$1:A$#,(A$1:A$#<>""Not found"")*(B$1:B$#=B1),""Not found""),1)", "#", lr)
    Intersect(.EntireRow, Columns("A")).Value = .Value
    .ClearContents
  End With
End Sub
 
Upvote 0
Assuming column J is available as a helper (any other columns would do too), you could try this with a copy of your workbook.

VBA Code:
Sub rename()
  Dim lr As Long
 
  lr = Range("A" & Rows.Count).End(xlUp).Row
  With Range("J1:J" & lr)
    .Formula = Replace("=INDEX(FILTER(A$1:A$#,(A$1:A$#<>""Not found"")*(B$1:B$#=B1),""Not found""),1)", "#", lr)
    Intersect(.EntireRow, Columns("A")).Value = .Value
    .ClearContents
  End With
End Sub
Peter you are a Genius! Thanks a lot!!
 
Upvote 0

Forum statistics

Threads
1,213,492
Messages
6,113,967
Members
448,537
Latest member
Et_Cetera

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