Results 1 to 6 of 6

"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. #1
    New Member
    Join Date
    Jul 2002
    Posts
    1

    Default

    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. #2
    MrExcel MVP phantom1975's Avatar
    Join Date
    Jun 2002
    Location
    Omaha, Nebraska
    Posts
    3,945

    Default

    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?
    Silly Billy was here....

    ***************** EXCEL/VB NEWBIES ARE MY FAVORITE! *****************

  3. #3
    MrExcel MVP lenze's Avatar
    Join Date
    Feb 2002
    Location
    Helena, MT
    Posts
    13,690

    Default

    If I understand you correctly, this should work.

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

  4. #4
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    56,346

    Default


    Also:


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


  5. #5
    Board Regular
    Join Date
    Mar 2002
    Location
    Hilo, Hawaii
    Posts
    240

    Default

    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. #6
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    56,346

    Default

    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?

    Aladin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com