Consulting

Results 1 to 4 of 4

Thread: Check game numbers

  1. #1

    Check game numbers

    Good afternoon,


    I need a VBA code so I can check all the cards, worksheet "Cards" with the worksheet results "Results", and the conference is done for each line of the "Cards" tab being checked

    throughout the range of the "Results" tab "is the total of hits placed in the" I "column of each game.

    Thanks a lot for the help.


    Romulo
    Attached Files Attached Files

  2. #2
    Good Morning,
    The statement is a bit confusing, here is some information to help me.
    1 - In each row of the Sheet "Cards" of column A the column G is a game;
    2 - I need a macro that can check each value of the cell if it is in the Range (B2: G100) of the sheet "Results" and put the number of hits of each game in column I of the sheet "Cards";
    I tried to make a macro but I curled myself into the search loop.


    Thank you very much

  3. #3
    Banned VBAX Newbie
    Joined
    Oct 2021
    Posts
    4
    Location
    mistake

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    I assumed that you wanted to compare Cards 1 to Results 1, Cards 2 to Results 2, etc.

    This is a simple way.

    Someone may have a clever worksheet formula


    Option Explicit
    
    
    Function Lottery(rCards As Range, rResults As Range) As Long
        Dim i As Long, n As Long, m As Long
        
        n = 0
        
        For i = 1 To 6
            m = 0
            On Error Resume Next
            m = Application.WorksheetFunction.Match(rCards.Cells(1, i).Value, rResults.Rows(1), 0)
            On Error GoTo 0
            n = n + IIf(m > 0, 1, 0)
        Next i
        
        Lottery = n
    End Function
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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