If row values found in another range, return a specific value, else leave original value intact

TropicalMagic

New Member
Joined
Jun 19, 2021
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hi all,



I would like to:



Check if row value in Column AN can be found in another workbook's Range("D2:D30")



If true, then return "APAC" in Column AM.

If false, do nothing and leave row value as it is.



However, my formula entered below is returning 1s and FALSE:


Range("AM2")

=IF(COUNTIF('[LOCATION & DISTRICT.xlsx]LOCATION'!$D$2:$D$30, AN2), AM2 = "APAC")



How to ensure that the row values returned are either "APAC" or original value?



Many thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about
Excel Formula:
=IF(COUNTIF('[LOCATION & DISTRICT.xlsx]LOCATION'!$D$2:$D$30, AN2), "APAC","")
 
Upvote 0
How about
Excel Formula:
=IF(COUNTIF('[LOCATION & DISTRICT.xlsx]LOCATION'!$D$2:$D$30, AN2), "APAC","")
Hi, thanks for the response! However, the same issue persists, only "APAC" or blank rows remain due to circular referencing. Nonetheless, I have created another column to place the formula in
 
Upvote 0
If you are putting that formula into AM2 then there is no circular reference in that formula.
 
Upvote 0
If you are putting that formula into AM2 then there is no circular reference in that formula.
Hi, I've instead decided to create more columns instead of confining the output to a single column:


ORIG_COUNTRY column row values may not be in the Range("D2:D31") despite having "APAC" ORIG_REGION column row value.


Hence, I included a new column, ORIG_COUNTRY_IN_LOCATION_LIST? =IF(COUNTIF(LOCATION'!$D$2:$D$31,AS2),"Y","N") to check if ORIG_COUNTRY column row values are in the Range("D2:D31").


Next, I created a new column, ORIG_COUNTRY_APAC REGION_BUT_NOT_IN_LIST =IF(AND(AN2="APAC",AO2="N"),"NULL","FALSE") to check if both the ORIG_REGION = "APAC" and ORIG_COUNTRY_IN_LOCATION_LIST? = "N"


Those row values with "NULL" means the ORIG_REGION row value = "APAC" but ORIG_COUNTRY row value is not of "APAC" ORIG_REGION (Wrong information)


Finally, I created a new column, FINAL_ORIG_REGION =IF(AP2="FALSE",AN2,"NULL") to output row values as "NULL" if corresponding row values ORIG_REGION = "APAC" and ORIG_COUNTRY_IN_LOCATION_LIST? = "N", correcting the wrong information.



Many thanks and hope this helps!



You can refer to the screenshot's final 2 rows for more clarification.
 

Attachments

  • SCREENSHOT.png
    SCREENSHOT.png
    18.2 KB · Views: 22
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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