仅复制格式,不复制条件

仅复制格式,不复制条件

当格式是由“条件格式”派生而来时,如何才能仅复制单元格的格式,但不复制条件?

答案1

我只找到了这个方法:

使用 vba,运行此子程序:

Sub Keep_Format()    
    Dim xRg As Range
    Dim xTxt As String
    Dim xCell As Range
    On Error Resume Next
    If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
    Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
    End If
    Set xRg = Application.InputBox("Select range:", "tools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    For Each xCell In xRg
        With xCell
          .Font.FontStyle = .DisplayFormat.Font.FontStyle
          .Interior.Color = .DisplayFormat.Interior.Color
          .Font.Strikethrough = .DisplayFormat.Font.Strikethrough
        End With
    Next
    xRg.FormatConditions.Delete
End Sub

相关内容