Option Explicit
Sub GetFormatting1()
Cells.Select
Selection.Clear
Selection.NumberFormat = "@"
ActiveWindow.DisplayGridlines = False
Dim nRow As Long, nCol As Long, nLastCol As Long, nLastRow As Long, i As Long
Dim wsR As Worksheet, wsF As Worksheet, wsD As Worksheet
Dim bGridlines As Boolean
Set wsR = Worksheets("Report")
Set wsF = Worksheets("Trial")
Set wsD = Worksheets("Dump")
nLastCol = 7 'wsR.Cells(1, Columns.Count).End(xlToLeft).Column
nLastRow = 5 'wsR.Cells(Rows.Count, nLastCol).End(xlDown).Row
wsR.Activate
bGridlines = ActiveWindow.DisplayGridlines
wsD.Activate
wsD.Cells.Clear
i = 0
With wsR
For nRow = 2 To nLastRow
For nCol = 1 To nLastCol
With .Cells(nRow, nCol)
wsF.Cells(i + 1, 1) = ""
wsF.Cells(i + 2, 1) = "/* Beginning of information for the cell " & .Address & " */" 'Chr(39)
wsF.Cells(i + 3, 1) = ".Address" & " = " & .Address
wsF.Cells(i + 4, 1) = ".Formula" & " = " & Chr(34) & WorksheetFunction.Substitute(.Formula, """", """""") & Chr(34)
wsF.Cells(i + 5, 1) = ".Value" & " = " & WorksheetFunction.Text(.Value, .NumberFormat)
wsF.Cells(i + 6, 1) = ".NumberFormat" & " = " & Chr(34) & WorksheetFunction.Substitute(.NumberFormat, """", """""") & Chr(34)
wsF.Cells(i + 7, 1) = ".HorizontalAlignment" & " = " & .HorizontalAlignment
wsF.Cells(i + 8, 1) = ".VerticalAlignment" & " = " & .VerticalAlignment
wsF.Cells(i + 9, 1) = ".WrapText" & " = " & .WrapText
wsF.Cells(i + 10, 1) = ".Orientation" & " = " & .Orientation
wsF.Cells(i + 11, 1) = ".IndentLevel" & " = " & .IndentLevel
wsF.Cells(i + 12, 1) = ".Font.Name" & " = " & Chr(34) & .Font.Name & Chr(34)
wsF.Cells(i + 13, 1) = ".Font.Size" & " = " & .Font.Size
wsF.Cells(i + 14, 1) = ".Font.Bold" & " = " & .Font.Bold
wsF.Cells(i + 15, 1) = ".Font.Italic" & " = " & .Font.Italic
wsF.Cells(i + 16, 1) = ".Font.Underline= .Font.Underline"
wsF.Cells(i + 17, 1) = ".Font.Strikethrough" & " = " & .Font.Strikethrough
wsF.Cells(i + 18, 1) = ".Font.Superscript" & " = " & .Font.Superscript
wsF.Cells(i + 19, 1) = ".Font.Subscript" & " = " & .Font.Subscript
wsF.Cells(i + 20, 1) = ".Font.Color" & " = " & .Font.Color
wsF.Cells(i + 21, 1) = ".Font.ColorIndex" & " = " & .Font.ColorIndex
wsF.Cells(i + 22, 1) = ".Interior.Color" & " = " & .Interior.Color
wsF.Cells(i + 23, 1) = ".Interior.ThemeColor" & " = " & .Interior.ThemeColor
wsF.Cells(i + 24, 1) = ".Font.TintAndShade" & " = " & .Interior.TintAndShade
wsF.Cells(i + 25, 1) = ".ColumnWidth" & " = " & .ColumnWidth
wsF.Cells(i + 26, 1) = ".RowHeight" & " = " & .RowHeight
wsF.Cells(i + 27, 1) = ".Borders.ColorIndex " & " = " & .Borders.ColorIndex
wsF.Cells(i + 28, 1) = ".Interior.PatternColor" & " = " & .Interior.PatternColorIndex
wsF.Cells(i + 29, 1) = ".Interior.PatternThemeColor" & " = " & .Interior.PatternThemeColor
wsF.Cells(i + 30, 1) = ".Interior.TintAndShade" & " = " & .Interior.TintAndShade
wsF.Cells(i + 31, 1) = ".Interior.PatternTintAndShade" & " = " & .Interior.PatternTintAndShade
wsF.Cells(i + 32, 1) = "/* End of the information for the cell " & .Address & " */" 'Chr(39)
wsF.Cells(i + 33, 1) = ""
wsF.Cells(i + 34, 1) = "'*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*"
'Windows("Report").DisplayGridlines = Windows("Dump").DisplayGridlines
'Windows(2).DisplayGridlines = Windows(1).DisplayGridlines
wsD.Activate
ActiveWindow.DisplayGridlines = bGridlines
ActiveWindow.FreezePanes = False
wsD.Cells(nRow, nCol).Formula = .Formula
wsD.Cells(nRow, nCol).Value = .Value
wsD.Cells(nRow, nCol).NumberFormat = .NumberFormat
wsD.Cells(nRow, nCol).HorizontalAlignment = .HorizontalAlignment
wsD.Cells(nRow, nCol).VerticalAlignment = .VerticalAlignment
wsD.Cells(nRow, nCol).WrapText = .WrapText
wsD.Cells(nRow, nCol).Orientation = .Orientation
wsD.Cells(nRow, nCol).IndentLevel = .IndentLevel
wsD.Cells(nRow, nCol).Font.Name = .Font.Name
wsD.Cells(nRow, nCol).Font.Size = .Font.Size
wsD.Cells(nRow, nCol).Font.Bold = .Font.Bold
wsD.Cells(nRow, nCol).Font.Italic = .Font.Italic
wsD.Cells(nRow, nCol).Font.Underline = .Font.Underline
wsD.Cells(nRow, nCol).Font.Strikethrough = .Font.Strikethrough
wsD.Cells(nRow, nCol).Font.Superscript = .Font.Superscript
wsD.Cells(nRow, nCol).Font.Subscript = .Font.Subscript
'wsD.Cells(nRow, nCol).Font.Color = .Font.Color .Font.ColorIndex ' .Interior.Color '
'MsgBox ConditionalColor(wsR.Cells(nRow, nCol), "Font")
wsD.Cells(nRow, nCol).Font.ColorIndex = ConditionalColor(wsR.Cells(nRow, nCol), "Font")
wsD.Cells(nRow, nCol).Interior.ColorIndex = ConditionalColor(wsR.Cells(nRow, nCol), "Interior")
'wsD.Cells(nRow, nCol).Interior.ThemeColor = .Interior.ThemeColor
'wsD.Cells(nRow, nCol).Font.TintAndShade = .Font.TintAndShade
wsD.Cells(nRow, nCol).ColumnWidth = .ColumnWidth
wsD.Cells(nRow, nCol).RowHeight = .RowHeight
' For the EdgeTop Border
If wsR.Cells(nRow, nCol).Borders(xlEdgeTop).LineStyle <> xlLineStyleNone Then
wsD.Cells(nRow, nCol).Borders(xlEdgeTop).LineStyle = wsR.Cells(nRow, nCol).Borders(xlEdgeTop).LineStyle
wsD.Cells(nRow, nCol).Borders(xlEdgeTop).Weight = wsR.Cells(nRow, nCol).Borders(xlEdgeTop).Weight
wsD.Cells(nRow, nCol).Borders(xlEdgeTop).ColorIndex = wsR.Cells(nRow, nCol).Borders(xlEdgeTop).ColorIndex
Else
wsD.Cells(nRow, nCol).Borders(xlEdgeTop).LineStyle = xlLineStyleNone
End If
End With
i = i + 34
Next nCol
Next nRow
wsD.Range("H2").Select
ActiveWindow.FreezePanes = True
wsD.Range("A1").Select
Application.ScreenUpdating = False
End With
wsF.Activate
wsF.UsedRange.Font.Size = 9
wsF.UsedRange.Font.Bold = False
wsF.UsedRange.Rows.HorizontalAlignment = xlLeft
wsF.UsedRange.Rows.VerticalAlignment = xlCenter
wsF.UsedRange.Rows.RowHeight = 12
wsF.UsedRange.ColumnWidth = 42
wsF.UsedRange.IndentLevel = 1
' wsF.Range("A:A").ColumnWidth = 84
wsF.UsedRange.Columns.WrapText = True
wsF.UsedRange.Rows.AutoFit
wsF.UsedRange.Borders.Color = 1
'Application.CutCopyMode = False
Application.ScreenUpdating = False
wsF.Rows("$1:$1").Select
ActiveWindow.FreezePanes = True
wsF.Rows("$1:$1").RowHeight = 33
ActiveWindow.ScrollRow = 1
Range("A1").Select
End Sub
Bookmarks