# "if-then" conditional statement to determine ....

This is a discussion on "if-then" conditional statement to determine .... within the Excel Questions forums, part of the Question Forums category; Is it possible to write an "if-then" conditional statement to determine if a cell contains a specific text sequence? For ...

1. Is it possible to write an "if-then" conditional statement to determine if a cell contains
a specific text sequence? For example, I need to construct the formula to say the
following:
if cell A1 contains the text sequence "NW" and A2 is > 90, then add 180 to A2 (and
correspondingly if cell A1 does not contain the text sequence "NW" and A2 is > 90,
then add 0 to A2).

So, how can I write a conditional statement of "if it contains [a text character]"?
This is for a large spreadsheet of geologic orientation data in what is called
"quadarant" format and I am trying to convert it to "azimuth" format.

Many, Many thanks for any ideas that you can give me!!!!

Brian

2. Welcome to the Board!!!!

There are two way to do it. The best way is with VBA code, but I'll provide you the means in a formula. If you are comfortable with VBA, I'll send you that code.

Tell me if this works.

In cell A3 put the following:

=if(and(A1="NW",A2>90),A2+180,A2+0)

Did this work?

3. If I understand you correctly, this should work.

=IF(AND(A1="NW",A2>90),A2+180,A2)

4. Also:

=(A2>90)*(A1="NW")*180+A2

5. Just to give you a jump start look at this

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Range("A1").Value Like "*NW*" Then
If Range("B2").Value = 1 Then GoTo 6
If Range("A2").Value > 90 Then
Range("A2").Value = Range("A2").Value + 180
Range("B2").Value = 1
Else
Range("A2").Value = Range("A2").Value + 0
End If
End If
6
End Sub

Changing B2 to 1 and checking for that lets the routine run only once

Yours in EXCELent Frustration

KniteMare

6. On 2002-07-26 10:17, KniteMare wrote:
Just to give you a jump start look at this

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Range("A1").Value Like "*NW*" Then
If Range("B2").Value = 1 Then GoTo 6
If Range("A2").Value > 90 Then
Range("A2").Value = Range("A2").Value + 180
Range("B2").Value = 1
Else
Range("A2").Value = Range("A2").Value + 0
End If
End If
6
End Sub

Changing B2 to 1 and checking for that lets the routine run only once

Yours in EXCELent Frustration

KniteMare
In all earnest, What is wrong with using a simple formula for this?