#1
|
|||
|
|||
if (text) then [value1, value2,,[
Is it possible to analyse text in Excel in cells in a column and use true/false outcomes to select a value from a vector (or column as I suppose you experts call it) and to output that value to a different cell ? eg A1 has text value green, B1 has numerical value n1, C1 acquires value n1 from B1, D1 acquires value 0 or blank; A2 has text value blue, B2 has value n2, C2 acquires 0 or blank, D2 acquires value n2 from B2; A3 has text value green. B3 has value n3, C3 acquires value n3 from B3, D3 acquires value zero or blank; ... Sorry I tried to lay this out as a table, but the forum text editor didn't like it - great for a forum on Excel, eh? Anyway I hope this makes sense and that there is a nice simple solution that I've just overlooked. Thanks, Andrew Last edited by adj1; 05-28-2011 at 10:05 AM. Reason: does not display as expected |
#2
|
||||
|
||||
Hi Andrew and welcome to the forum.
Quote:
If I understand correctly, you're saying that if column A is "Green" then column C should pick up the value from column B, but if column A is "Blue" then column D should pick up the value from column B? In cell C1 put this formula: Code:
=IF(A1="Green",B1,0) Code:
=IF(A1="Blue",B1,0) |
#3
|
|||
|
|||
Dear Colin Many thanks both for reply and for amazing swiftness. Silly of me not to think of attaching a file. That's pretty much what I want but when I tried that form of IF statement in Office 2010 it didn't work. Now it may well be my lack of experience of 2010, or with IF statements, or just plain carelessness, so I'll have another try and let you know how it goes. Thanks again, Andrew
Last edited by adj1; 05-29-2011 at 03:35 AM. Reason: got it wrong |
#4
|
|||
|
|||
Problem solved
Dear Coliin Worked like a charm. Many, many thanks - I might even be able to finish my tax in time. Comment: You have to put in the full text of the column being used to sort on, it doesn't seem to like using only the first letter or word, but that's ok as long as it's not too long, though it gets a bit tedious when there are many diffferent texts to deal with. Now if only one could add several text choices into one column - e.g. IF either "yellow" or "blue" then green column acquires the value of the associated cell - but one can just add the columns afterwards, so it's no great hardship. Saved me having to resurrect my rusty BASIC - many thanks again Best wishes, andrew
|
#5
|
||||
|
||||
Hi Andrew,
Quote:
Code:
=IF(ISNUMBER(SEARCH("blue",A1)),B1,0) Code:
=IF(OR(ISNUMBER(SEARCH({"blue","yellow"},A1))),B1,0) Code:
=IF(OR(ISNUMBER(SEARCH({"red","blue","orange"},A1))),B1,0) Note - SEARCH() is not case sensitive. If you want the formula to be case sensitive then use FIND() instead of SEARCH(). |
#6
|
|||
|
|||
Yes!
Wow ! and yes please, I'd love to know - since I've started this, I may as well get up to speed on every aspect for next time, because I can see it coming. Thanks, Andrew
|
#7
|
||||
|
||||
Sure,
If you put the list of colours, say red, blue and orange into cells J1:J3, two options would be: (1) Use the same formula as above, but with the array constant replaced by the range and enter it as an array formula. To do this, when you type the formula into the formula bar, finish the entry with CTRL+SHIFT+ENTER instead of just ENTER. If done correctly then Excel will automatically surround the formula with braces { } (you can't manually enter these yourself). Code:
{=IF(OR(ISNUMBER(SEARCH(J1:J3,A1))),B1,0)} Use a variation such as this one (which can be entered as a normal formula). Code:
=IF(SUMPRODUCT(--ISNUMBER(SEARCH(J1:J3,A1))),B1,0) |
#8
|
|||
|
|||
Gratitude
Dear Colin Thanks again. My apologies for not replying before -among other distractions, Microsoft is suddenly trying to claim that my W7 is illegitimate and has blocked the registration key - I bought this W7 from them, so I can understand their concern... Anyway my thanks for all the work you have put into clarifying what I probably ought to have been able to work out for myself, and at least I am better informed if no less an idiot. Best wishes, Andrew
|
Tags |
if-then, text dependency |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to find text in between two characters and then format selected text? | qcom | Word | 5 | 02-19-2015 11:23 PM |
Need help on Macro 03- Find text - if text is blank then remove line | simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
Objective: Automatically export email text,attachment text to DB friendly format | SilentLee | Outlook | 0 | 11-14-2010 02:45 PM |
Templates: automatic text generation from Rich Text content control | Chickenmunga | Word | 0 | 10-01-2008 11:16 AM |
Cells with wrap text not showing text | lazylew | Excel | 1 | 08-31-2008 06:58 AM |