在VBA流程设置后,为什么不能编辑格式?

如何解决在VBA流程设置后,为什么不能编辑格式?

我有一些代码可以设置工作表的格式(见下文)。

但是一旦设置了格式,用户便无法在事后更改它。

格式化是业务流程的一部分,用于标准化外观,使其准备好进行报告,但是在报告审阅过程中,审阅者可能会更改内容,做法是将单元格黄色突出显示(或将字体变为红色)。指出他们在哪里进行了更改。

由于我的代码设置了单元格颜色和字体颜色,因此它们现在似乎无法执行任何操作。

在代码执行后,如何使此内容再次可编辑的任何想法?

谢谢

Sub FormatCCO()

'Turn off pop-up alerts which are caused by having moved many WIP sheets over with the same dropdown list names
    Application.DisplayAlerts = False

'Turn off screen updating for smoother look and feel
    Application.ScreenUpdating = False
    
'Delete the sheet "CCO Formatted" if it exists
    On Error Resume Next
    ActiveWorkbook.Worksheets("CCO Formatted").Delete
    On Error GoTo 0

'Create a copy of the Combined sheet and rename it CCO Formatted,placing it in 2nd tab position
    Sheets("Combined").Select
    Sheets("Combined").Copy Before:=Sheets(2)
    Sheets("Combined (2)").Select
    Sheets("Combined (2)").Name = "CCO Formatted"

'Delete all columns not required for CCO reporting (including last rows with the Peoplesoft Tiers
    Sheets("CCO Formatted").Range("A:A,F:F,O:O,P:P,S:U,W:Y,AC:AC,AH:AJ,AL:AT,AY:BF").EntireColumn.Delete

'Move status to Column E (after Allegation but before Date Opened)
    Columns("i:i").Select
    Selection.Cut
    Columns("e:e").Select
    Selection.Insert Shift:=xlToRight

'Format rows 2:350 - remove cell colouring,turn text to verdana 9pt black
    Rows("2:350").Select
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    With Selection.font
        .Name = "Verdana"
        .Size = 9
        .bold = False
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

' Centre (horizontally and vertically) all colummns,then only left align Allegation (c),Key Factors (i) Investigation status (j). Autofit height
Range("a:aa").HorizontalAlignment = xlCenter
Range("a:aa").VerticalAlignment = xlCenter
Rows("2:350").AutoFit
Range("C:C,I:I,J:J").HorizontalAlignment = xlLeft


'Re-bold header row and Days Open column
    Rows("1:1").Select
    Selection.font.bold = True
    Columns("H:H").Select
    Selection.font.bold = True

'Sort by [Date Opened]
    If Not ActiveSheet.AutoFilterMode Then
        ActiveSheet.Range("A1").AutoFilter
    End If
    
    ActiveWorkbook.Worksheets("CCO Formatted").AutoFilter.Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("CCO Formatted").AutoFilter.Sort.SortFields.Add Key _
        :=Range("f1:f350"),SortOn:=xlSortOnValues,Order:=xlAscending,DataOption _
        :=xlSortNormal
    With ActiveWorkbook.Worksheets("CCO Formatted").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
'Apply conditional formatting to [Raised Profile] Cases
    Range("A2:G350,I2:AA350").Select
    Selection.FormatConditions.Add Type:=xlExpression,Formula1:= _
        "=$r2=""Yes"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = RGB(255,220,185)
    End With
     With Selection.FormatConditions(1).font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    Selection.FormatConditions(1).StopIfTrue = False

'Apply conditional formatting to cases where [Status] is 'Closed'
    Range("A2:G350,Formula1:= _
        "=$E2=""CLOSED"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = RGB(153,204,255)
        .TintAndShade = 0
    End With
     With Selection.FormatConditions(1).font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    Selection.FormatConditions(1).StopIfTrue = False

'Break external links (from migrating from WIP backups)
Call BreakExternalLinks

' Reset borders from A1 across to the last row and column
Dim lngLstCol As Long,lngLstRow As Long

    lngLstRow = ActiveSheet.UsedRange.Rows.Count
    lngLstCol = ActiveSheet.UsedRange.Columns.Count

    For Each rngCell In Range(Range("a1"),Cells(lngLstRow,lngLstCol))
        If rngCell.Value > "" Then
            rngCell.Select 'Select cells
            With Selection.Borders
                .LineStyle = xlContinuous
                .Weight = xlThin
                .ColorIndex = xlAutomatic
            End With
        End If
    Next

'Return cursor to cell A1
Application.GoTo Reference:=Range("a1"),Scroll:=True

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com(将#修改为@)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?