![]() |
How do I implement if-else functionalilty for a cell in excel?
I want to have two cells with one cell depending on the other value. Ex. If
A1=Raja then A2 should display 11, else if A1=Chirala, then A2 should display 12. Please give information on this if this type of programming is possible in excel. |
How do I implement if-else functionalilty for a cell in excel?
In A2, =if(a1="Raja",11,if(a1="Chirala",12,""))
A2 will display blank if neither condition is met. Raja Suman wrote: I want to have two cells with one cell depending on the other value. Ex. If A1=Raja then A2 should display 11, else if A1=Chirala, then A2 should display 12. Please give information on this if this type of programming is possible in excel. |
How do I implement if-else functionalilty for a cell in excel?
you could use select case
Sub test() Dim nm As String nm = Range("A1").Value Select Case nm Case "raja" Range("a2").Value = 11 Case "Chirala" Range("A2").Value = 12 Case Else Range("a2").Value = "" End Select End Sub -- Gary "Raja Suman" <Raja wrote in message ... I want to have two cells with one cell depending on the other value. Ex. If A1=Raja then A2 should display 11, else if A1=Chirala, then A2 should display 12. Please give information on this if this type of programming is possible in excel. |
How do I implement if-else functionalilty for a cell in excel?
Here is the If ...Then...ElseIf code:
Sub RajChi() If Range("$A$1").Value = "Raja" Then Range("$A$2").Value = "11" ElseIf Range("$A$1").Value = "Chirala" Then Range("$A$2").Value = "12" End If End Sub This works on a pass basis. That is, if a name is in the cell when the code runs you will get the appropriate number. However, if you change the name and don't run the code again, the number does not change. "Raja Suman" wrote: I want to have two cells with one cell depending on the other value. Ex. If A1=Raja then A2 should display 11, else if A1=Chirala, then A2 should display 12. Please give information on this if this type of programming is possible in excel. |
All times are GMT +1. The time now is 08:33 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com