Need Excel formula to Pick value based on conditions

Aswinraj

Board Regular
Joined
Dec 10, 2015
Messages
65
Hi Friends,

I wonder whether any formulas available for changing the data based on certain conditions.

Example Based on Below Table:

If Last 3 Letters in Column B is "mer" and Column A is "9G" then in Column C - it has to give as "SG"
else it has to give the same data in Column A.


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]9G[/TD]
[TD]Consumer[/TD]
[/TR]
[TR]
[TD]9T[/TD]
[TD]Mobility[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]Mobility[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]8N[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]TA[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]MP[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]B6U[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]B8J[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BAN[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]9G[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BFF[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BAN[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BGB[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]9G[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BTA[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commercial[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]9G[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Consumer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD="class: xl65, width: 130"]BFD[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 188"]
<tbody>[TR]
[TD="class: xl65, width: 188"]Commer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
How about this in C1

=IF(AND(RIGHT(B1,3)="mer",A1="9G"),"SG",A1)
 
Upvote 0
Hi mse330,

Now the formula is if B column contains "Mer" and A column contains 9G then it will display "SG".

Just to learn, is it possible to have two condition..?? I mean, if B column contains "Mer" and A column contains "9G" and "GG" then it should display "SG".
 
Upvote 0
Something like...

=IF(AND(ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH("9G","GG",$A1))),ISNUMBER(SEARCH("mer",$B1)),"SG","")
 
Upvote 0
Hi mse330,

Just to learn, is it possible to have two condition..?? I mean, if B column contains "Mer" and A column contains "9G" and "GG" then it should display "SG".

So column A should include both "9G" & "GG" or either one ?
 
Upvote 0
@mse330 I found it., =IF(AND(RIGHT(B13,3)="mer",A13="9G",A13="GG"),"SG",A13) - it works.

But i Missed to provide some informations, sorry.., Actually it needs to pickup the data from one sheet to another sheet.
Please help..,


Example:
Sheet 1 Data:

It contains 3 Columns A, B and C..,

If Last 3 Letters in Column B is "mer" and Column A is "9G" and "GG"

Sheet 2 Data


If Last 3 Letters in Column B is "mer" and Column A is "9G" and "GG" then it has to pickup the data from Column C - Book 1.

Like a Vlookup.


With Regards,
Aswinraj A
 
Last edited:
Upvote 0
@Aswinraj


I don't think this formula is correct/logical
=IF(AND(RIGHT(B13,3)="mer",A13="9G",A13="GG"),"SG",A13) … This will never return "SG" as it is evaluating the content in cell A13 to be "9G" & "GG" … Maybe this is what you're looking for =IF(AND(RIGHT(B13,3)="mer",OR(A13="9G",A13="GG")),"SG",A13)

What is in column C in sheet 1 ? Would a vlookup work? Or it should just take the value of column C in the same row ?
 
Upvote 0
Try to post 5 rows from Sheet1 and 5 rows from Sheet2 and describe the results which must obtain.
@Aladin Akyurek @mse330

From Sheet 1: If Last 3 Letters in Column B is "mer" and Column A is "9G" and "GG" then it has to lookup with

Sheet 2
If Last 3 Letters in Column B is "mer" and Column A is "9G" and "GG" then it has to pickup the data from Column C in Sheet 1.

Hope now its clear :)
:):)
Sheet 1 Table
[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]9G[/TD]
[TD]Consumer[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]9T[/TD]
[TD]Commerical[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]Mobile[/TD]
[TD]8000[/TD]
[/TR]
[TR]
[TD]GG[/TD]
[TD]Consumer[/TD]
[TD]77[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2 Table
[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]9G[/TD]
[TD]Consumer[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]FT[/TD]
[TD]Comm[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]GG[/TD]
[TD]Consumer[/TD]
[TD]77[/TD]
[/TR]
[TR]
[TD]PF[/TD]
[TD]Mobile[/TD]
[TD]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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