Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
comparing text in if statement
ok, I give up, I can't find my answer by searching... I have a cell that contains a text string, depending on what letter that string starts with, I need to use a particular formula. I am trying to accomplish this in VB, but have had no luck getting my if statement to work... example A B C 1 ip30 Formula 1 result i 2 np30 Formula 2 result 3 ip35 Formula 1 result using the above sheet as reference, column A is the only column that I will be entering data.....here is what I want my if/then statement to look like if(left(range(targetAddress),1) = c1 then ***use formula 1 *** else ***use formula 2*** end if keep in mind this is part of a sub that is executed anytime a value in column A changes. So as soon as I enter my data in column A, the macro runs and fills out the rest of my columns for me, but how it fills out the other columns is dependant on the first character of the string entered in column A. I hope this makes sense. If not say so and will try and clarify. Thanks in advance for any help. -- Dolemite ------------------------------------------------------------------------ Dolemite's Profile: http://www.excelforum.com/member.php...o&userid=26136 View this thread: http://www.excelforum.com/showthread...hreadid=396993 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
comparing text in if statement
Does this help?
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 1 And Target.Row 1 _ And Target.Value < Empty Then If Target.Offset(0, 2).Value < Empty Then If Left(Target.Value, 1) = Target.Offset(0, 2).Value Then Target.Offset(0, 3).FormulaR1C1 = "Formula A" Else Target.Offset(0, 3).FormulaR1C1 = "Formula B" End If End If End If End Sub Regards Rowan "Dolemite" wrote: ok, I give up, I can't find my answer by searching... I have a cell that contains a text string, depending on what letter that string starts with, I need to use a particular formula. I am trying to accomplish this in VB, but have had no luck getting my if statement to work... example A B C 1 ip30 Formula 1 result i 2 np30 Formula 2 result 3 ip35 Formula 1 result using the above sheet as reference, column A is the only column that I will be entering data.....here is what I want my if/then statement to look like if(left(range(targetAddress),1) = c1 then ***use formula 1 *** else ***use formula 2*** end if keep in mind this is part of a sub that is executed anytime a value in column A changes. So as soon as I enter my data in column A, the macro runs and fills out the rest of my columns for me, but how it fills out the other columns is dependant on the first character of the string entered in column A. I hope this makes sense. If not say so and will try and clarify. Thanks in advance for any help. -- Dolemite ------------------------------------------------------------------------ Dolemite's Profile: http://www.excelforum.com/member.php...o&userid=26136 View this thread: http://www.excelforum.com/showthread...hreadid=396993 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do you do an IF statement in Excel comparing three columns | Excel Worksheet Functions | |||
If statement comparing times | Excel Worksheet Functions | |||
Comparing 2 text cells in an if statement | Excel Discussion (Misc queries) | |||
Comparing Model Numbers without a giant IF statement | Excel Worksheet Functions | |||
IF statement comparing month and year separately | Excel Worksheet Functions |