我对此代码有疑问,我无法解决。
我有两套范围;范围(“C14:C19”)和范围(“E14:E19”)每个包含6个随机生成的数字(我已编码随机选择)。
我的目标是,在生成数字后,比较两个范围。 如果两个范围包含相同的数字, 我希望MsgBox在两个范围中找到相同数量的数量,以及每个数字的值。
示例: 生成数字后,如果两个范围的值共有9和7,则MsgBox看起来像:
获胜组合中有2个数字,其中/的值是:7,9
这是我迄今为止所做的事情。
Private Sub Compare()
Dim rgnChoix As Range, rgnTirage As Range, i As Range, j As Range, iVal As Integer
Set rgnChoix = Range("C14:C19")
Set rgnTirage = Range("E14:E19")
For Each i In rgnChoix.Cells
For Each j In rgnTirage.Cells
If i.value = j.value Then
MsgBox "There is/are" & " " & iVal & " " & "number(s) in the winning combination and it's/there value(s) is/are :" & " " & i.value, , "Erika"
Exit Sub
End If
Next j
Next i
iVal = Application.WorksheetFunction.CountIf(Range("C14:C19"),"i.value=j.value")
End Sub
谢谢! 梨香