如何在受保护的Excel工作表上启用Cell重新调整大小

时间:2015-09-25 18:35:40

标签: excel vba excel-vba

我有一个宏根据其他行的值禁用某行,女巫工作正常

 Private Sub Worksheet_Change(ByVal Target As Range)
    Call SecurityColumnsLookup(Target)
End Sub
Private Sub Workbook_Open(ByVal Target As Range)
    Call SecurityColumnsLookup(Target)
End Sub
Private Sub SecurityColumnsLookup(ByVal Target As Range)
On Error GoTo MyErr
    Err.Clear
    ActiveSheet.Unprotect

    Application.EnableEvents = False
 Select Case Range("V" & (Target.Row)).Value
   //do stuff


    End Select
 ActiveSheet.Protect
    Application.EnableEvents = True
    Exit Sub
MyErr:
    On Error Resume Next
 ActiveSheet.Protect
    Application.EnableEvents = True
    Exit Sub
End Sub
 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Call SecurityColumnsLookup(Target)
    End Sub

我想知道的是如何将代码添加到我的宏中以便允许用户重新调整行的大小,因为现在正在发生的事情是当宏处于活动状态并且鼠标悬停在单元格上时重新调整大小图标不会出现

是否可以随时启用重新sizet功能?

谢谢

1 个答案:

答案 0 :(得分:1)

我找到了问题的解决方案,如此链接中所述

http://www.thespreadsheetguru.com/the-code-vault/2014/2/21/protect-worksheet-but-allow-formatting-and-hiding-rows-columns

添加此

    ActiveSheet.Protect , AllowFormattingColumns:=True, AllowFormattingRows:=True
Application.EnableEvents = True

让我的宏启用调整大小选项!