如果我的用户表单有选项卡,如何在提交后清除Excel用户表单?

时间:2018-02-13 14:55:34

标签: excel vba forms userform

我有一个正在进行的3标签用户表单,我希望能够用它来帮助人们在营销活动中注册事项,并且几乎完美无缺,除非人们点击“提交”后会发生什么。这是我到目前为止看起来的VBA代码:

Private Sub CommandButton_Submit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customer Information")

[...]

Me.TextBox1_First.Value = ""
Me.TextBox2_Last.Value = ""
Me.TextBox3_Email.Value = ""
Me.TextBox4_Phone.Value = ""
`end of the first userform tab
Me.TextBox5_Address.Value = ""
Me.TextBox6_City.Value = ""
Me.ComboBox1_State.Value = ""
Me.TextBox8_Zip.Value = ""
`end of the second tab
Me.OptionButton1_Electric.Value = ""
Me.OptionButton2_Gas.Value = ""
Me.OptionButton3_Oil.Value = ""
Me.OptionButton4_Propane.Value = ""
Me.OptionButton5_OtherHeat.Value = ""
Me.OptionButton6_Eversource.Value = ""
Me.OptionButton7_Muni.Value = ""
Me.OptionButton8_NGrid.Value = ""
Me.OptionButton9_OtherCo.Value = ""
Me.OB_Yes.Value = ""
Me.OB_No.Value = ""
`end of form
Application.ScreenUpdating = False
Unload Me
Page1.show
Application.ScreenUpdating = True

End Sub


Private Sub UserForm_Initialize()
Me.MultiPage1.Value = 0
Me.TextBox1_First.SetFocus
End Sub

这上面有一些输入数据的东西,但是工作正常。问题是我复制的这部分似乎没有做任何事情。它不会清除表单,也不会将用户返回到第一页,焦点在第一个文本框上,如预期的那样。很高兴澄清人们需要的任何其他要点!

1 个答案:

答案 0 :(得分:0)

将其更改为“文字”

Me.TextBox1_First.Text = "" Me.TextBox2_Last.Text = "" Me.TextBox3_Email.Text = "" Me.TextBox4_Phone.Text = ""