获取选取的单元格格式
Sub GetSelectedCellFormat()
' 定义变量
Dim rng As Range
Dim cell As Range
Dim result As String
Dim rgbColor As String
' 获取当前选定的区域
Set rng = Selection
' 初始化结果字符串
result = "选中的区域格式信息:" & vbCrLf
' 获取选定区域的第一个单元格的格式信息
With rng.Cells(1, 1)
result = result & "字体: " & .Font.Name & vbCrLf
result = result & "字号: " & .Font.Size & vbCrLf
result = result & "颜色: RGB(" & .Font.Color & ")" & vbCrLf
result = result & "背景色: RGB(" & .Interior.Color & ")" & vbCrLf
result = result & "框线类型: " & .Borders.LineStyle & vbCrLf
' 将框线颜色转换为RGB格式
rgbColor = "RGB(" & .Borders.Color & ")"
result = result & "框线颜色: " & rgbColor & vbCrLf
End With
' 将结果放置在A10单元格
Range("A10").Value = result
End Sub