EXCEL VBA代码问题
以下代码,请高人给出每一句的注解。谢谢!!PrivateSubCommandButton3_Click()DimiAsIntegerDimCunZaiAsBooleanD...
以下代码,请高人给出每一句的注解。谢谢!!
Private Sub CommandButton3_Click()
Dim i As Integer
Dim CunZai As Boolean
Dim icount As Integer
Worksheets("订单表").Activate
icount = Worksheets("订单表").[a6556].CurrentRegion.Rows.Count + 6555
CunZai = False
For i = 2 To icount
If ComboBox1.Text <> "" Then
If ComboBox1.Text = Cells(i, 1) Then
CunZai = True
Rows(i).Select
Selection.Delete
Worksheets("订单表").Activate
Rows(i + 13).Select
Selection.Delete
Sheet1.Select
ComboBox1.Value = ""
MsgBox "删除成功!", vbOKOnly, "提示"
Exit For
End If
Else
Sheet1.Select
MsgBox "请选择要删除的订单编号", vbOKOnly, "提示"
Exit Sub
End If
Next i
End Sub 展开
Private Sub CommandButton3_Click()
Dim i As Integer
Dim CunZai As Boolean
Dim icount As Integer
Worksheets("订单表").Activate
icount = Worksheets("订单表").[a6556].CurrentRegion.Rows.Count + 6555
CunZai = False
For i = 2 To icount
If ComboBox1.Text <> "" Then
If ComboBox1.Text = Cells(i, 1) Then
CunZai = True
Rows(i).Select
Selection.Delete
Worksheets("订单表").Activate
Rows(i + 13).Select
Selection.Delete
Sheet1.Select
ComboBox1.Value = ""
MsgBox "删除成功!", vbOKOnly, "提示"
Exit For
End If
Else
Sheet1.Select
MsgBox "请选择要删除的订单编号", vbOKOnly, "提示"
Exit Sub
End If
Next i
End Sub 展开
展开全部
Private Sub CommandButton3_Click()
Dim i As Integer '定义整型变量i
Dim CunZai As Boolean '定义布尔型变量CunZai
Dim icount As Integer '定义整型变量icount
Worksheets("订单表").Activate '工作簿表格-订单表-激活
icount = Worksheets("订单表").[a6556].CurrentRegion.Rows.Count + 6555 '判断单元格a6556后还有多少行数据,并再加6555行
CunZai = False 'cunzai设置为假
For i = 2 To icount '循环从2开始到icount
If ComboBox1.Text <> "" Then '当combobox1里的数据不为空则执行以下内容
If ComboBox1.Text = Cells(i, 1) Then '判断单元格i,1里的内容是否等于combobox1里的内容,如果等于执行以下内容
CunZai = True 'cunzai赋值为真
Rows(i).Select 'i行被选择
Selection.Delete '删除选择的行
Worksheets("订单表").Activate '激活工作表 订单表
Rows(i + 13).Select 'i+13行选择
Selection.Delete '删除选择的行
Sheet1.Select '选择工作表sheet1
ComboBox1.Value = "" 'combobox1值清空
MsgBox "删除成功!", vbOKOnly, "提示" '弹出对话框
Exit For '退出for循环
End If
Else
Sheet1.Select '选择工作表sheet1
MsgBox "请选择要删除的订单编号", vbOKOnly, "提示" '弹出对话框
Exit Sub '退出过程
End If
Next i
End Sub
Dim i As Integer '定义整型变量i
Dim CunZai As Boolean '定义布尔型变量CunZai
Dim icount As Integer '定义整型变量icount
Worksheets("订单表").Activate '工作簿表格-订单表-激活
icount = Worksheets("订单表").[a6556].CurrentRegion.Rows.Count + 6555 '判断单元格a6556后还有多少行数据,并再加6555行
CunZai = False 'cunzai设置为假
For i = 2 To icount '循环从2开始到icount
If ComboBox1.Text <> "" Then '当combobox1里的数据不为空则执行以下内容
If ComboBox1.Text = Cells(i, 1) Then '判断单元格i,1里的内容是否等于combobox1里的内容,如果等于执行以下内容
CunZai = True 'cunzai赋值为真
Rows(i).Select 'i行被选择
Selection.Delete '删除选择的行
Worksheets("订单表").Activate '激活工作表 订单表
Rows(i + 13).Select 'i+13行选择
Selection.Delete '删除选择的行
Sheet1.Select '选择工作表sheet1
ComboBox1.Value = "" 'combobox1值清空
MsgBox "删除成功!", vbOKOnly, "提示" '弹出对话框
Exit For '退出for循环
End If
Else
Sheet1.Select '选择工作表sheet1
MsgBox "请选择要删除的订单编号", vbOKOnly, "提示" '弹出对话框
Exit Sub '退出过程
End If
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询