Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2011, 09:34 AM
adj1 adj1 is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Novice
if (text) then [value1, value2,,[
 
Join Date: May 2011
Posts: 11
adj1 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 05-29-2011, 03:13 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Hi Andrew and welcome to the forum.
Quote:
Originally Posted by adj1 View Post
Sorry I tried to lay this out as a table, but the forum text editor didn't like it
You can always attach an example workbook to the thread?


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)
In cell D1 put this formula:
Code:
=IF(A1="Blue",B1,0)
__________________
Colin

RAD Excel Blog
Reply With Quote
  #3  
Old 05-29-2011, 03:30 AM
adj1 adj1 is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Novice
if (text) then [value1, value2,,[
 
Join Date: May 2011
Posts: 11
adj1 is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 05-31-2011, 02:38 PM
adj1 adj1 is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Novice
if (text) then [value1, value2,,[
 
Join Date: May 2011
Posts: 11
adj1 is on a distinguished road
Default 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
Reply With Quote
  #5  
Old 05-31-2011, 03:10 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Hi Andrew,
Quote:
Originally Posted by adj1 View Post
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.....
It's possible to do partial matches too. For example, to see if A1 contains the word "blue" you can use:
Code:
=IF(ISNUMBER(SEARCH("blue",A1)),B1,0)
You can then extend it for multiple words. To see if A1 contains the words "blue" or "yellow" you can use:
Code:
=IF(OR(ISNUMBER(SEARCH({"blue","yellow"},A1))),B1,0)
To see if a cell contains "red", "blue" or "orange" you can use:
Code:
=IF(OR(ISNUMBER(SEARCH({"red","blue","orange"},A1))),B1,0)
If you want to put the list of colours in a range and reference them (rather than using an array constant {.....}) then you have to use something slightly different - let me know if you want to do this and I'll show you how.

Note - SEARCH() is not case sensitive. If you want the formula to be case sensitive then use FIND() instead of SEARCH().
__________________
Colin

RAD Excel Blog
Reply With Quote
  #6  
Old 05-31-2011, 03:22 PM
adj1 adj1 is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Novice
if (text) then [value1, value2,,[
 
Join Date: May 2011
Posts: 11
adj1 is on a distinguished road
Default 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
Reply With Quote
  #7  
Old 06-01-2011, 01:57 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

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)}
(2)
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)
__________________
Colin

RAD Excel Blog
Reply With Quote
  #8  
Old 06-06-2011, 04:31 AM
adj1 adj1 is offline if (text) then [value1, value2,,[ Windows 7 32bit if (text) then [value1, value2,,[ Office 2010 32bit
Novice
if (text) then [value1, value2,,[
 
Join Date: May 2011
Posts: 11
adj1 is on a distinguished road
Default 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
Reply With Quote
Reply

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
if (text) then [value1, value2,,[ 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft