VBA or formula to copy value from one column into another column where certain conditions are met.

junkforhr

Board Regular
Joined
Dec 16, 2009
Messages
115
Office Version
  1. 365
Platform
  1. Windows
I have a dataset (see example below)

Where Key_Text equals AAAInterventionType, where the Ref matches, find AAAReviewReason in the Key_Text column return the value of Key_Code in the column called ReviewReason.

DTSRefKEY_TextKEY_Code
11/04/2023 8:03​
9995aAAAChannelPHO
11/04/2023 8:03​
9995aAAAInterventionStatusSTA
11/04/2023 8:03​
9995aAAAInterventionTypeIQI
11/04/2023 8:03​
9995aAAAOriginINT
11/04/2023 8:03​
9995aAAAReviewReasonCDI
11/04/2023 8:05​
9995aAAAChannelPHO
11/04/2023 8:05​
9995aAAAInterventionStatusSTA
11/04/2023 8:05​
9995aAAAInterventionTypeIQI
11/04/2023 8:05​
9995aAAAOriginINT
11/04/2023 8:05​
9995aAAAReviewReasonCDI
11/04/2023 8:06​
9995aAAAChannelPHO
11/04/2023 8:06​
9995aAAAInterventionStatusSTA
11/04/2023 8:06​
9995aAAAInterventionTypeIQI
11/04/2023 8:06​
9995aAAAOriginINT
11/04/2023 8:06​
9995aAAAReviewReasonCDI


Desired Outcome

DTSRefKEY_TextKEY_CodeReviewReason
11/04/2023 8:03​
9995aAAAChannelPHO
11/04/2023 8:03​
9995aAAAInterventionStatusSTA
11/04/2023 8:03​
9995aAAAInterventionTypeIQICDI
11/04/2023 8:03​
9995aAAAOriginINT
11/04/2023 8:03​
9995aAAAReviewReasonCDI
11/04/2023 8:05​
9995aAAAChannelPHO
11/04/2023 8:05​
9995aAAAInterventionStatusSTA
11/04/2023 8:05​
9995aAAAInterventionTypeIQICDI
11/04/2023 8:05​
9995aAAAOriginINT
11/04/2023 8:05​
9995aAAAReviewReasonCDI
11/04/2023 8:06​
9995aAAAChannelPHO
11/04/2023 8:06​
9995aAAAInterventionStatusSTA
11/04/2023 8:06​
9995aAAAInterventionTypeIQICDI
11/04/2023 8:06​
9995aAAAOriginINT
11/04/2023 8:06​
9995aAAAReviewReasonCDI
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Like this?

23 07 05.xlsm
BCDE
1RefKEY_TextKEY_Code
29995aAAAChannelPHO 
39995aAAAInterventionStatusSTA 
49995aAAAInterventionTypeIQICDI
59995aAAAOriginINT 
69995aAAAReviewReasonCDI 
79995aAAAChannelPHO 
89995aAAAInterventionStatusSTA 
99995aAAAInterventionTypeIQICDI
109995aAAAOriginINT 
119995aAAAReviewReasonCDI 
129995aAAAChannelPHO 
139995aAAAInterventionStatusSTA 
149995aAAAInterventionTypeIQICDI
159995aAAAOriginINT 
169995aAAAReviewReasonCDI 
Get Code
Cell Formulas
RangeFormula
E2:E16E2=IF(C2="AAAInterventionType",INDEX(D:D,AGGREGATE(15,6,ROW(D$2:D$16)/((C$2:C$16="AAAReviewReason")*(B$2:B$16=B2)),1)),"")
 
Upvote 1
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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