'If' with text values

L

Liam

Hello All,

I think my pascal background is hampering me here. All I need to do is
is this -

If the numercial value in A1 is 1 then make the text value in A2
'hello'
If the numercial value in A1 is 2 then make the text value in A2
'goodbye'

I have the structure but just can't get the syntax correct - can anyone
help please?

Thanks Liam.
 
L

Liam

Thanks Tom, Sorry I wan't clear enough!

There are a whole bunch of possible values and outcomes, way too many
for a nested IF statement approach.

I was looking for a VB solution something along the lines of Case or If
?
 
B

Bob Phillips

Try

=CHOOSE(H1,"A","B","C","D")

just extend the list as needed.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
T

Tom Ogilvy

Easier to create a table of numbers in the left column and results in the
right column, then use

=if(A1="","",vlookup(A1,Sheet2!A1:B1000,2,False))


Otherwise

Select Case Range("A1").Value
Case 1
res = "Hello"
Case 2
res = "Goodbye"
Case Else
res = "Not found"
End Select Case

msgbox Res
 

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