Excel Formula help (if/or)

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Code:
Hi Team,

I am looking for a formula in B3, Such a that if I found a Cell value (Gold or Silver)
in Cell A3, then I want the answer Best in Column (b3). 
Else dont change any value in B3. Then i want to drag the formula till last cell value.

Through Filtering I can get the result, I am looking for a formula as a replacement for Filtering.


[TABLE="width: 128"]
 <colgroup><col width="64" style="width:48pt" span="2"> </colgroup><tbody>[TR]
  [TD="width: 64, bgcolor: #E26B0A"][B][FONT=Calibri][SIZE=3][COLOR=#000000]A[/COLOR][/SIZE][/FONT][/B][/TD]
  [TD="width: 64, bgcolor: #E26B0A"][B][FONT=Calibri][SIZE=3][COLOR=#000000]B[/COLOR][/SIZE][/FONT][/B][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: #76933C"][FONT=Calibri][SIZE=3][COLOR=#000000]Product[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: #76933C"][FONT=Calibri][SIZE=3][COLOR=#000000]Status[/COLOR][/SIZE][/FONT][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]Gold[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]BEST[/COLOR][/SIZE][/FONT][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#000000]alsk[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#000000]Old data [/COLOR][/SIZE][/FONT][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]Silver[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]BEST[/COLOR][/SIZE][/FONT][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#000000]safdsa[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT][/TD]
 [/TR]
 [TR]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]Gold[/COLOR][/SIZE][/FONT][/TD]
  [TD="bgcolor: #FABF8F"][FONT=Calibri][SIZE=3][COLOR=#000000]BETS[/COLOR][/SIZE][/FONT][/TD]
 [/TR]
</tbody>[/TABLE]
<strike></strike>

Regards
Mallesh
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Code:
I am looking for a formula in B3, Such a that if I found a Cell value (Gold or Silver)
in Cell A3, then I want the answer Best in Column (b3). 
Else dont change any value in B3. Then i want to drag the formula till last cell value.[/QUOTE]
You cannot do that with a formula. A cell can only contain one thing... a formula or data... if you put a formula in a cell, that formula cannot see the data that existed beforehand. You will need to use a VBA macro to do what you asked for.
[CODE][table="width: 500"]
[tr]
	[td]Sub GoldSilverBest()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "B").End(xlUp).Row
  Range("B1:B" & LastRow) = Evaluate(Replace("IF((A1:A#=""Gold"")+(A1:A#=""Silver""),""BEST"",B1:B#)", "#", LastRow))
End Sub[/td]
[/tr]
[/table]

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (GoldSilverBest) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Thanks Rick for quick solution and with Nice explaination !!!
 
Upvote 0
Hi Rick,

Just tested on Macro, it works but on blank cell it gives zero Value. I want as it is,
blank for blank, old value = will be old value and for Gold/Silver = Best

I am new in vba, what it means :=> A1:A# and Term Evaluate. which are in your code. Thanks.



Regards,
Mallesh
 
Upvote 0

Forum statistics

Threads
1,215,176
Messages
6,123,464
Members
449,100
Latest member
sktz

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