单击Excel按钮后无法编辑单元格的值

问题描述:

我有一个宏从命名范围中删除一行。
按下按钮运行该宏后,我无法编辑单元格了。
不在该范围内,也不在受保护的工作表中的任何可编辑单元格中。
似乎具有相同代码的工作簿在Excel 2010中也不起作用。
这是我的宏:
单击Excel按钮后无法编辑单元格的值

Sub DeleteParameterRow(ByVal tCell As Range) 

    '''this procedure delete a row from one of the parameters lists 
    On Error GoTo ErrHandler 

    Application.EnableEvents = False 
    Application.DisplayAlerts = False 

    Dim iRowToDelete As Integer 

    Call Unprotect_All() 

    If IsPartOfRange(tCell, NamedRange("Param_ParametersList"), False) Then 

     tCell.Delete Shift:=xlUp 

    Else 

     MsgBox("Please select one of the parameters list", vbInformation, "Error") 

    End If 

EndProc: 
    Call Protect_All() 
    Application.DisplayAlerts = True 
    Application.EnableEvents = True 
    Exit Sub 

ErrHandler: 
    MsgBox(Err.Description, vbCritical, Err.Number) 
    GoTo EndProc 

End Sub 


Function IsPartOfRange(ByVal rSearchRange As Range, ByVal rSearchInRange As Range, ByVal bIsEntireRange As Boolean) As Boolean 
    '''this function gets a small range, a big range and if it is supposed to be the entire range, and check 
    '''if the smaller range is part of the bigger one, and if it is the entire range 
    IsPartOfRange = False 

    If Not Intersect(rSearchRange, rSearchInRange) Is Nothing Then 

     If bIsEntireRange = True Then 

      If rSearchRange.Address = rSearchInRange.MergeArea.Address Then IsPartOfRange = True 

     Else 

      IsPartOfRange = True 

     End If 

    End If 

End Function 
+0

请提供一些代码供我们查看,看看我们是否可以重现。你现在在运行什么版本的Excel?你真正的问题是什么? –

+0

是否在宏的开始处禁用事件,然后不在最后重新启用它们?获得更多的上下文(和代码)以帮助我们会很有帮助。 – sous2817

+2

寻求调试帮助的问题(“为什么这个代码不工作?”)必须包含所需的行为,特定的问题或错误以及在问题本身中重现问题所需的最短代码。没有明确问题陈述的问题对其他读者无益。 –

见我最后的评论是我提到这似乎是一种“刷新”的问题。
代码运行后,在Excel中堆叠了一些可防止编辑的东西。 (No way to report bugs to MS... :(
要以编程方式强制执行“刷新”,我发现清除任意单元格的内容是有用的。
因此添加行tCell.ClearContents befor EndProc:做了trik。

+0

我重新打开答案,因为我发现在另一个工作簿中,它不工作:( –