Multiple address lines in an 'if'

L

Learner101b

I want to insert an address into a merged cell depending on a location cell.
When I use the code below, Excel does not recognize the <alt enter>. Any
ideas?

=IF(E2=1,"ABC Company<alt enter>123 Street<alt enter>Anytown, State
Zip","DEF Company<alt enter>456 Road<alt enter>Anytown, State Zip")

The <alt enter> does not work in this text box, but I think you will
understand what I want to do.

Thanks for any help.
Learner101b
 
Y

Yanick

Use this.

=IF(E2=1,"ABC Company" & CHAR(10) & "123 Street" & CHAR(10) & "Anytown,
StateZip","DEF Company" & CHAR(10) & "456 Road" & CHAR(10) & "Anytown, State
Zip")

You need to check the "wrap text" box in the cell alignment format.
 
D

Dave Peterson

And you really used alt-enter instead of this literal <alt-enter>, right?

Did you remember to turn on wraptext?

Format|Cells|Alignment tab|check Wrap Text
(xl2003 menus)

And remember that merged cells don't react nicely to autofitting the rowheight.
You'll have to adjust that manually.
 
L

Learner101b

Works like a charm. Thank you very much.

Curiosity question:
How did you know a 'return' was 'char' 10?

Learner010b
 
Y

Yanick

I knew it for my C++ programming in DOS. ASCII code for line feed is 10.

Take a look there to have a list of all code
http://www.asciitable.com/

I am sure you can have a lot of info on google if you search for ASCII.

Have fun!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top