PDA

View Full Version : Check game numbers



Romulo Avila
11-05-2018, 10:29 AM
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

Romulo Avila
11-07-2018, 03:49 AM
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

KeiranLee
10-13-2021, 09:09 AM
mistake

Paul_Hossler
10-13-2021, 01:25 PM
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