“单元格格式”很复杂。单元格实际上没有“格式”。它们有字体(本身有名称和大小)、NumberFormat、Height、Width、Orientation 等。
因此,您需要定义“格式”的含义。
下面是获取字体名称和大小的代码。您可以替换任何您喜欢的属性。
下面的代码假定您在工作簿中创建了一个名为“格式”的工作表。运行宏后,字体名称和大小将列在该工作表中。
Public Sub GetFormats()
Dim CurrentSheet As Integer
Dim UsedRange As Range
Dim CurrentCell As Range
Dim rw As Long
Sheets("Formats").Cells.ClearContents
rw = 1
For CurrentSheet = 1 To Sheets.Count
Set UsedRange = Range(Sheets(CurrentSheet).Range("A1"), Sheets(CurrentSheet).Range("A1").SpecialCells(xlLastCell))
For Each CurrentCell In UsedRange
FontUsed = CurrentCell.Font.Name + ":" + CStr(CurrentCell.Font.Size)
If Sheets("Formats").Cells.Find(FontUsed) Is Nothing Then
Sheets("Formats").Cells(rw, 1).Value = FontUsed
rw = rw + 1
End If
Next
Next CurrentSheet
End Sub