Why not use this.....

    Select Case Cells(2, j).Value
        Case "sexta-feira"
            Select Case Cells(i, 1).Value
                Case *512, 513, 516*
                    MsgBox "Yay"
                Case Else
                    MsgBox "Aw"
            End Select
        Case Else
            'Do Nothing
    End Select

Regards,
Sam Mathai Chacko

On Fri, Jul 27, 2012 at 7:27 PM, Jorge Marques <leote.w...@gmail.com> wrote:

> Hi,
> Ok I looked in several forums none explained, I only noticed then the code
> only returns 1 Case or "OR", the issue is that I have a Shops in this case
> they are code 513, 512, 516, and if it is "Sexta-feira" (Friday) that
> should sum the values one day ahead. My idea of Case statement was just
> trying to avoid several If statements, so I thought Case would be a
> solution.
>
> I´ll try your suggestion and adapt to the rules. Meanwhile I attached the
> file that I forgot, sorry for that. Thanks :)
>
>
>
>
> 2012/7/27 Paul Schreiner <schreiner_p...@att.net>
>
>> The "Select Case" condition could be used to replace a "OR" condition.
>> not really an "AND" condition.
>> Kind-of.
>> It's really more like replacing ElseIF.
>>
>> For instance, you could use:
>> both of these examples yield the same result:
>>
>>  '--------------------------------------------------------------------
>>     TestVal = "three"
>>     '--------------------------------------------------------------------
>>     Select Case UCase(TestVal)
>>         Case "ONE"
>>             MsgBox "TestVal = ONE"
>>         Case "TWO"
>>             MsgBox "TestVal = TWO"
>>         Case "THREE"
>>             MsgBox "TestVal = THREE"
>>         Case "FOUR"
>>             MsgBox "TestVal = FOUR"
>>         Case Else
>>             MsgBox "TestVal is not a member of the expected list"
>>     End Select
>>     '--------------------------------------------------------------------
>>     If (UCase(TestVal) = "ONE") Then
>>             MsgBox "TestVal = ONE"
>>     ElseIf (UCase(TestVal) = "TWO") Then
>>             MsgBox "TestVal = TWO"
>>     ElseIf (UCase(TestVal) = "THREE") Then
>>             MsgBox "TestVal = THREE"
>>     ElseIf (UCase(TestVal) = "FOUR") Then
>>             MsgBox "TestVal = FOUR"
>>     Else
>>             MsgBox "TestVal is not a member of the expected list"
>>     End If
>>     '--------------------------------------------------------------------
>>
>> In your example, I think the problem is with the conditional "grouping"
>> you need to use ( ) to group the things together, like;
>> If (((Cells(2, j).Value = "sexta-feira") And (Cells(i, 1).Value = 512)) _
>>  Or ((Cells(2, j).Value = "sexta-feira") And (Cells(i, 1).Value = 513)) _
>>  Or ((Cells(2, j).Value = "sexta-feira") And (Cells(i, 1).Value = 516)) _
>> ) Then
>> End If
>>     '--------------------------------------------------------------------
>> Since the first part of each -And- condition is the same, you could use:
>> If ((Cells(2, j).Value = "sexta-feira") And _
>>     ((Cells(i, 1).Value = 512) _
>>   Or (Cells(i, 1).Value = 513) _
>>   Or (Cells(i, 1).Value = 516) _
>>    )) Then
>> End If
>>
>> '--------------------------------------------------------------------
>>  If you absolutely INSIST that you need to use a "case" statement,
>> then I suppose you could use:
>>
>> If (Cells(2, j).Value = "sexta-feira") Then
>>     Select Case (Cells(i, 1).Value)
>>         Case 512
>>
>>             Cells(i, j + 1).Value = Cells(i, j + 1).Value + Cells(i,
>> j).Value
>>         Case 513
>>
>>             Cells(i, j + 1).Value = Cells(i, j + 1).Value + Cells(i,
>> j).Value
>>         Case 516
>>
>>             Cells(i, j + 1).Value = Cells(i, j + 1).Value + Cells(i,
>> j).Value
>>     End Select
>> End If
>>     '--------------------------------------------------------------------
>>
>>
>> *Paul*
>>
>> -----------------------------------------
>> *“Do all the good you can,
>> By all the means you can,
>> In all the ways you can,
>> In all the places you can,
>> At all the times you can,
>> To all the people you can,
>> As long as ever you can.” - John Wesley
>> *-----------------------------------------
>>
>>
>>  ------------------------------
>> *From:* NOORAIN ANSARI <noorain.ans...@gmail.com>
>> *To:* excel-macros@googlegroups.com
>> *Sent:* Fri, July 27, 2012 7:29:07 AM
>> *Subject:* Re: $$Excel-Macros$$ Turning a if macro to a select case macro
>>
>> Dear Jorge,
>>
>> Please share sample workbook.
>>
>> On Wed, Jul 25, 2012 at 3:36 PM, Jorge Marques <leote.w...@gmail.com>wrote:
>>
>>> Hi guys, can anybody help me turning this If macro to an case macro.
>>>
>>>  Sub friday()
>>>
>>> For i = 1 To 200
>>> For j = 1 To 200
>>>
>>> If Cells(2, j).Value = "sexta-feira" And Cells(i, 1).Value = 512 Or
>>> Cells(2, j).Value = "sexta-feira" And Cells(i, 1).Value = 513 Or Cells(2,
>>> j).Value = "sexta-feira" And Cells(i, 1).Value = 516 Then
>>> Cells(i, j + 1).Value = Cells(i, j + 1).Value + Cells(i, j).Value
>>> End If
>>> Next
>>> Next
>>> End Sub
>>>
>>> Thank you in advance :).
>>>
>>> --
>>> --
>>> FORUM RULES (986+ members already BANNED for violation)
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>> will not get quick attention or may not be answered.
>>>
>>> 2) Don't post a question in the thread of another member.
>>>
>>> 3) Don't post questions regarding breaking or bypassing any security
>>> measure.
>>>
>>> 4) Acknowledge the responses you receive, good or bad.
>>>
>>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>>> signatures are prohibited.
>>>
>>> NOTE : Don't ever post personal or confidential data in a workbook.
>>> Forum owners and members are not responsible for any loss.
>>>
>>>
>>> ------------------------------------------------------------------------------------------------------
>>> To post to this group, send email to excel-macros@googlegroups.com
>>>
>>> To unsubscribe, send a blank email to
>>> excel-macros+unsubscr...@googlegroups.com
>>>
>>>
>>>
>>
>>
>>
>> --
>> With Regards,
>> Noorain Ansari
>> http:// 
>> <http://www.noorainansari.com/>noorainansari.com<http://www.noorainansari.com/>
>> http:// <http://www.excelvbaclinic.blogspot.com/>
>> excelvbaclinic.blogspot.com <http://www.excelvbaclinic.blogspot.com/>
>> http://accesssqclinic.blogspot.in/
>>
>>
>>
>>
>> --
>> --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE : Don't ever post personal or confidential data in a workbook. Forum
>> owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> To unsubscribe, send a blank email to
>> excel-macros+unsubscr...@googlegroups.com
>>
>>
>>
>> --
>> --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE : Don't ever post personal or confidential data in a workbook. Forum
>> owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> To unsubscribe, send a blank email to
>> excel-macros+unsubscr...@googlegroups.com
>>
>>
>>
>
>  --
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>
>
>



-- 
Sam Mathai Chacko

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


Reply via email to