Else if in excel?

munkifisht

New Member
Joined
Mar 17, 2005
Messages
39
I was wondering how you can create an else if statment in excel?

I have a cell that will be filled with one of ten options, for convienence lets say they are 0-9. Depending in the value of the cell, I want to fill another with a value, say a letter. Also, if another nominated cell is filled, I want this one to override the second cell and for it to generate a different unique value in tyhe target cell.

Lets say
if
a1-blank
a2-1
then
a3-a
if
a1-blank
a2-4
a3-j
but if
a1-10
a2-any 1-9
a3-will look at a1 and give "u"
 
You can continue your logic, just plug it into the correct syntax ...


Code:
if range("a1") = vbNullString then
if range("a2") = 1 then
    range("a3") = "a"
elseif range("a2") = 4 then
    range("a3") = "j"
end if
'...
end if

You can continue on like this. It's somewhat hard to follow what you are looking at, and it would seem (right off hand) that their may be an easier way, it just depends on what your data structure is.
 
Upvote 0
Sorry bout my language bk there, Aight!!! I' is tryin nowz to keepz it real fo da homz! Ahhhh Yea!

Thanks man, how would I make that into a function in excel? I have never done that before?
 
Upvote 0
Well, you could use the IF function, but you can only nest 7 of them. An example would look like this ...

(assumed to be in A3)
=IF(A1="",IF(A2=1,"a",IF(A2=2,"J","else..")))
 
Upvote 0

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