+ Reply to Thread
Results 1 to 5 of 5

Multiple like statements?

  1. #1

    Multiple like statements?

    Hello,

    Is it possible to use more than one LIKE statment in an Excel Macro?

    Here is what I have:

    WHERE CAR.FAC_NO = HEAD.FAC_NO AND ((BALANCE.COMP='NIL') AND
    (BALANCE.YEAR=2005) AND (BALANCE.PER_NO=99) AND (BALANCE.ACCOUNT Like
    '5%') AND (HEAD.AREA like '333%'))

    Which works...

    But, I want to add more LIKE statments.

    i.e. ....AND (HEAD.AREA like '666%') AND (HEAD.AREA like '999%'))

    How ever I get errored out.

    The LIKE statements grabs groups of number with a common beginning
    three digits. But it seems I can only do it for only one set, number
    multiple numbers.

    Any suggestions?

    Tmuld


  2. #2
    Norman Jones
    Guest

    Re: Multiple like statements?

    Hi T,

    Sub TestIt()

    If CAR.FAC_NO = HEAD.FAC_NO Then
    If BALANCE.COMP = "NIL" Then
    If BALANCE.Year = 2005 Then
    If BALANCE.PER_NO = 99 Then
    If BALANCE.ACCOUNT Like "5%" Then
    If HEAD.AREA Like "333%" Then
    If HEAD.AREA Like "666%" Then
    If HEAD.AREA Like "999%" Then

    'Your result code here

    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If

    End Sub

    Note, all single quotes changed to double quotes.

    ---
    Regards,
    Norman



    <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > Is it possible to use more than one LIKE statment in an Excel Macro?
    >
    > Here is what I have:
    >
    > WHERE CAR.FAC_NO = HEAD.FAC_NO AND ((BALANCE.COMP='NIL') AND
    > (BALANCE.YEAR=2005) AND (BALANCE.PER_NO=99) AND (BALANCE.ACCOUNT Like
    > '5%') AND (HEAD.AREA like '333%'))
    >
    > Which works...
    >
    > But, I want to add more LIKE statments.
    >
    > i.e. ....AND (HEAD.AREA like '666%') AND (HEAD.AREA like '999%'))
    >
    > How ever I get errored out.
    >
    > The LIKE statements grabs groups of number with a common beginning
    > three digits. But it seems I can only do it for only one set, number
    > multiple numbers.
    >
    > Any suggestions?
    >
    > Tmuld
    >




  3. #3
    Tim Williams
    Guest

    Re: Multiple like statements?

    A number can't be like 666% and like 333%

    Pehaps you wanted to use OR ?

    WHERE
    CAR.FAC_NO = HEAD.FAC_NO AND
    BALANCE.COMP='NIL' AND
    BALANCE.YEAR=2005 AND
    BALANCE.PER_NO=99 AND
    BALANCE.ACCOUNT Like '5%'
    AND (HEAD.AREA like '333%' OR HEAD.AREA like '666%'))

    Tim


    <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > Is it possible to use more than one LIKE statment in an Excel Macro?
    >
    > Here is what I have:
    >
    > WHERE CAR.FAC_NO = HEAD.FAC_NO AND ((BALANCE.COMP='NIL') AND
    > (BALANCE.YEAR=2005) AND (BALANCE.PER_NO=99) AND (BALANCE.ACCOUNT
    > Like
    > '5%') AND (HEAD.AREA like '333%'))
    >
    > Which works...
    >
    > But, I want to add more LIKE statments.
    >
    > i.e. ....AND (HEAD.AREA like '666%') AND (HEAD.AREA like '999%'))
    >
    > How ever I get errored out.
    >
    > The LIKE statements grabs groups of number with a common beginning
    > three digits. But it seems I can only do it for only one set,
    > number
    > multiple numbers.
    >
    > Any suggestions?
    >
    > Tmuld
    >




  4. #4
    Tim Williams
    Guest

    Re: Multiple like statements?

    Norman,

    Looked like SQL to me....

    Tim


    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi T,
    >
    > Sub TestIt()
    >
    > If CAR.FAC_NO = HEAD.FAC_NO Then
    > If BALANCE.COMP = "NIL" Then
    > If BALANCE.Year = 2005 Then
    > If BALANCE.PER_NO = 99 Then
    > If BALANCE.ACCOUNT Like "5%" Then
    > If HEAD.AREA Like "333%" Then
    > If HEAD.AREA Like "666%" Then
    > If HEAD.AREA Like "999%" Then
    >
    > 'Your result code here
    >
    > End If
    > End If
    > End If
    > End If
    > End If
    > End If
    > End If
    > End If
    >
    > End Sub
    >
    > Note, all single quotes changed to double quotes.
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > <[email protected]> wrote in message
    > news:[email protected]...
    >> Hello,
    >>
    >> Is it possible to use more than one LIKE statment in an Excel
    >> Macro?
    >>
    >> Here is what I have:
    >>
    >> WHERE CAR.FAC_NO = HEAD.FAC_NO AND ((BALANCE.COMP='NIL') AND
    >> (BALANCE.YEAR=2005) AND (BALANCE.PER_NO=99) AND (BALANCE.ACCOUNT
    >> Like
    >> '5%') AND (HEAD.AREA like '333%'))
    >>
    >> Which works...
    >>
    >> But, I want to add more LIKE statments.
    >>
    >> i.e. ....AND (HEAD.AREA like '666%') AND (HEAD.AREA like '999%'))
    >>
    >> How ever I get errored out.
    >>
    >> The LIKE statements grabs groups of number with a common beginning
    >> three digits. But it seems I can only do it for only one set,
    >> number
    >> multiple numbers.
    >>
    >> Any suggestions?
    >>
    >> Tmuld
    >>

    >
    >




  5. #5
    Norman Jones
    Guest

    Re: Multiple like statements?

    Hi Tim,

    Yes, the initial WHERE should have alerted me.

    Thank yoiu.

    ---
    Regards,
    Norman



    "Tim Williams" <saxifrax@pacbell*dot*net> wrote in message
    news:[email protected]...
    > Norman,
    >
    > Looked like SQL to me....
    >
    > Tim
    >
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi T,
    >>
    >> Sub TestIt()
    >>
    >> If CAR.FAC_NO = HEAD.FAC_NO Then
    >> If BALANCE.COMP = "NIL" Then
    >> If BALANCE.Year = 2005 Then
    >> If BALANCE.PER_NO = 99 Then
    >> If BALANCE.ACCOUNT Like "5%" Then
    >> If HEAD.AREA Like "333%" Then
    >> If HEAD.AREA Like "666%" Then
    >> If HEAD.AREA Like "999%" Then
    >>
    >> 'Your result code here
    >>
    >> End If
    >> End If
    >> End If
    >> End If
    >> End If
    >> End If
    >> End If
    >> End If
    >>
    >> End Sub
    >>
    >> Note, all single quotes changed to double quotes.
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >>
    >> <[email protected]> wrote in message
    >> news:[email protected]...
    >>> Hello,
    >>>
    >>> Is it possible to use more than one LIKE statment in an Excel Macro?
    >>>
    >>> Here is what I have:
    >>>
    >>> WHERE CAR.FAC_NO = HEAD.FAC_NO AND ((BALANCE.COMP='NIL') AND
    >>> (BALANCE.YEAR=2005) AND (BALANCE.PER_NO=99) AND (BALANCE.ACCOUNT Like
    >>> '5%') AND (HEAD.AREA like '333%'))
    >>>
    >>> Which works...
    >>>
    >>> But, I want to add more LIKE statments.
    >>>
    >>> i.e. ....AND (HEAD.AREA like '666%') AND (HEAD.AREA like '999%'))
    >>>
    >>> How ever I get errored out.
    >>>
    >>> The LIKE statements grabs groups of number with a common beginning
    >>> three digits. But it seems I can only do it for only one set, number
    >>> multiple numbers.
    >>>
    >>> Any suggestions?
    >>>
    >>> Tmuld
    >>>

    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1