Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



wrote in message
ups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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


wrote in message
ups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Multiple like statements?

Norman,

Looked like SQL to me....

Tim


"Norman Jones" wrote in message
...
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



wrote in message
ups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
...
Norman,

Looked like SQL to me....

Tim


"Norman Jones" wrote in message
...
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



wrote in message
ups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple If Statements Tigerwould Excel Worksheet Functions 6 May 16th 08 11:49 AM
Multiple IF statements looking up multiple ranges. mike Excel Worksheet Functions 7 August 9th 07 04:55 PM
Multiple if statements with multiple conditions egarcia Excel Discussion (Misc queries) 4 January 29th 07 10:46 PM
Using multiple IF statements Jshendel Excel Discussion (Misc queries) 8 August 29th 06 09:04 PM
multiple IF statements Nathan McElmurry Excel Worksheet Functions 1 November 18th 04 09:22 PM


All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"