我希望我的代码返回随机名称

时间:2017-07-19 14:31:29

标签: vba excel-vba excel

您好我希望我的代码在文本框中返回随机名称,但它总是给我一个错误。这是我的代码:

Private Sub CommandButton1_Click()


 TextBox1.Text = Evaluate(Choose(RandBetween(1, 3), "Kwezi", "MAy", "FR"))
 TextBox2.Text = Evaluate(Choose(RandBetween(1, 3), "Kwezi", "MAy", "FR"))
 TextBox3.Text = Evaluate(Choose(RandBetween(1, 3), "Kwezi", "MAy", "FR"))


End Sub

1 个答案:

答案 0 :(得分:1)

Private Sub CommandButton1_Click()
    TextBox1.Text = Choose(WorksheetFunction.RandBetween(1, 3), "Kwezi", "MAy", "FR")
    TextBox2.Text = Choose(WorksheetFunction.RandBetween(1, 3), "Kwezi", "MAy", "FR")
    TextBox3.Text = Choose(WorksheetFunction.RandBetween(1, 3), "Kwezi", "MAy", "FR")
End Sub