Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
excel vba删除行宏返回“;“类型不匹配”;_Vba_Excel - Fatal编程技术网

excel vba删除行宏返回“;“类型不匹配”;

excel vba删除行宏返回“;“类型不匹配”;,vba,excel,Vba,Excel,如果您告诉它要删除的选定单元格由下拉列表中的一个部分#填写,则我的代码可以正常工作 但如果您键入新的或自定义的内容,然后希望删除该部分,则宏将返回 类型不匹配(错误13) 子删除行() Application.ScreenUpdating=False 关于错误转到哇 如果是ActiveCell.Row,您确定在.Delete上发生类型不匹配错误吗?错误发生在哪一行?我确定执行类似activeRowVariable.Rows(x:y)的操作。Delete应该足以完成作业 Sub DeleteRow

如果您告诉它要删除的选定单元格由下拉列表中的一个部分#填写,则我的代码可以正常工作

但如果您键入新的或自定义的内容,然后希望删除该部分,则宏将返回

类型不匹配(错误13)

子删除行()
Application.ScreenUpdating=False
关于错误转到哇

如果是ActiveCell.Row,您确定在
.Delete
上发生类型不匹配错误吗?错误发生在哪一行?我确定执行类似activeRowVariable.Rows(x:y)的操作。Delete应该足以完成作业
Sub DeleteRows()
Application.ScreenUpdating = False

On Error GoTo whoa

If ActiveCell.Row <= 8 Then
    MsgBox "Ooops!" & vbNewLine & _
    vbNewLine & "Please select a Part Number"
ElseIf MsgBox("Are you sure you want to delete this part?" & vbNewLine & _
              vbNewLine & _
              ActiveCell.EntireRow.Cells(1, "A").Value & vbNewLine & _
              ActiveCell.EntireRow.Cells(1, "B").Value & vbNewLine & _
              "QTY: " & ActiveCell.EntireRow.Cells(1, "M").Value, _
              vbYesNo) = vbYes Then
   ActiveCell.Resize(3, 1).EntireRow.Delete
End If
Application.ScreenUpdating = True
Exit Sub
whoa:
    MsgBox "Please select a number from the drop down list" & vbNewLine & _
    "then run the delete command again.", vbInformation, Err.Description
End Sub