Vba 用于确认数据更改操作的消息框
我的提交按钮代码如下:Vba 用于确认数据更改操作的消息框,vba,excel,Vba,Excel,我的提交按钮代码如下: Private Sub CommandButton1_Click() Sheets("Overall").Activate With Me If Len(.ComboBox1.Value) * Len(.TextBox1.Value) * Len(.ComboBox2.Value) * Len(.ComboBox3.Value) * Len(.TextBox2.Value) * Len(.TextBox3.Value) * Len(.ComboBox4.Va
Private Sub CommandButton1_Click()
Sheets("Overall").Activate
With Me
If Len(.ComboBox1.Value) * Len(.TextBox1.Value) * Len(.ComboBox2.Value) * Len(.ComboBox3.Value) * Len(.TextBox2.Value) * Len(.TextBox3.Value) * Len(.ComboBox4.Value) * Len(.ComboBox5.Value) * Len(.TextBox4.Value) * Len(.TextBox5.Value) * Len(.TextBox6.Value) * Len(.ComboBox6.Value) * Len(.TextBox7.Value) * Len(.TextBox8.Value) = 0 Then
MsgBox "Please Complete All Fields Before Submit"
Else
eRow = Sheet9.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(eRow, 1).Value = ComboBox1.Text
Cells(eRow, 2).Value = TextBox2.Text
Cells(eRow, 3).Value = TextBox3.Text
Cells(eRow, 4).Value = TextBox1.Text
Cells(eRow, 5).Value = ComboBox3.Text
Cells(eRow, 6).Value = TextBox4.Text
Cells(eRow, 7).Value = TextBox5.Text
Cells(eRow, 8).Value = ComboBox4.Text
Cells(eRow, 15).Value = ComboBox6.Text
Cells(eRow, 10).Value = ComboBox5.Text
Cells(eRow, 11).Value = TextBox7.Text
Cells(eRow, 12).Value = TextBox8.Text
Cells(eRow, 13).Value = TextBox6.Text
Cells(eRow, 14).Value = ComboBox2.Text
End If
End With
End Sub
我希望添加一个确认弹出消息框,提醒用户,如果在TextBox8中输入的值超过3.0
如果用户选择是,则仅将数据存储在excel工作表中,但如果用户选择否,将显示另一个弹出消息框,通知用户在TextBox8中重新键入值
我应该在vbYesNo消息框中的何处添加?在更改
单元格之前添加类似的内容:
If TextBox8.Value > 3 Then
If MsgBox("TextBox8 > 3" & vbCrLf & "Continue?", vbYesNo) = vbNo Then
MsgBox "Please change the value of TextBox8"
TextBox8.SetFocus
Else
'//eRow = ...
End If
End If
它将显示一个YesNo
MsgBox,要求用户继续。如果用户选择No
将显示第二个带有通知的MsgBox,然后文本框将被激活 在第一个Else
块之后添加另一个If
块。此外,您还应该对单元格(eRow,#)执行一些操作。值
作为Sheet9可能并不总是处于活动状态。请看这里,我的这篇文章有另一种方法,至少在理论上可能会感兴趣: