Option Explicit
Private Sub Worksheet_MouseDown(ByVal Button AsInteger, ByVal Shift AsInteger, ByVal X As Single, ByVal Y As Single)
Dim ws As Worksheet
Dim cell As Range
Dim prizeAmount AsDouble' 设置工作表和中奖号码
Set ws = ThisWorkbook.Worksheets("Sheet1")
ws.Range("A1").Value = Int((99 + 1) * Rnd()) ' 生成1-99的整数作为中奖号码
' 检查鼠标点击位置是否在刮奖区范围内
For Each cell In ws.Range("A2:Z2")
If cell.Address = "" Then Exit For
If cell.Row = X And cell.Column = Y Then
' 如果点击位置与中奖号码相同,则显示奖金金额
prizeAmount = ws.Cells(cell.Row, cell.Column + 1).Value
MsgBox "恭喜你中奖了!奖金为:" & Format(prizeAmount, "0.00") & "元"ExitFor
End If
Next cell
End Sub