Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Implement Hyperlink in Excel Worksheet using c# shantanu Excel Worksheet Functions 0 March 9th 07 10:14 AM
Implement object persistence inside Excel Tom Chau Excel Discussion (Misc queries) 2 April 7th 06 01:48 AM
WNetGetUniversalName - how to implement in VBA? KR Excel Programming 1 March 16th 06 03:48 PM
How would I implement this cell increment? Kia Excel Discussion (Misc queries) 3 January 4th 06 12:11 AM
How do I,implement a recurssive loop using Microsoft Excel ? Vikas_Yadav Excel Programming 1 August 10th 05 07:14 AM


All times are GMT +1. The time now is 09:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"