Problem

一个抽奖软件,效果图如下。
点击随机数或者按钮3会进行抽奖。
基于VBA的Excel抽奖软件

Solution

1、Excel打开开发者工具
基于VBA的Excel抽奖软件

2、插入按钮,选择指定宏
基于VBA的Excel抽奖软件
基于VBA的Excel抽奖软件

3、编写VBA程序
基于VBA的Excel抽奖软件

4、另存为启用宏的xlsm
基于VBA的Excel抽奖软件

Codes

Sub ASD_Click()
Dim a As Integer
Randomize
a = Int(Rnd() * 59 + 1)
Range("a14") = a
End Sub

Sub ASDF_Click()
Dim x, y As Integer
Randomize
x = Int(Rnd() * 8 + 1)
y = Int(Rnd() * 8 + 1)
Range("a1:h8").Interior.ColorIndex = xlNone
Cells(x, y).Interior.ColorIndex = 3
End Sub

相关文章:

  • 2021-12-28
  • 2021-12-15
  • 2021-08-30
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-25
  • 2021-11-19
  • 2021-11-19
  • 2021-12-15
  • 2021-11-19
  • 2021-11-19
相关资源
相似解决方案