为了保留源工作表的原始格式使用下面的:
For r = LBound(x, 1) To UBound(x, 1)
For c = LBound(x, 2) To UBound(x, 2)
NewWS.Rows(r).RowHeight = WS.Cells(r, c).RowHeight
NewWS.Columns(c).ColumnWidth = WS.Cells(r, c).ColumnWidth
With NewWS.Cells(r, c)
.Font.Bold = WS.Cells(r, c).Font.Bold
.Borders(xlEdgeBottom).LineStyle = WS.Cells(r, c).Borders(xlEdgeBottom).LineStyle
.Borders(xlEdgeLeft).LineStyle = WS.Cells(r, c).Borders(xlEdgeLeft).LineStyle
.Borders(xlEdgeRight).LineStyle = WS.Cells(r, c).Borders(xlEdgeRight).LineStyle
.Interior.ColorIndex = WS.Cells(r, c).Interior.ColorIndex
.Orientation = WS.Cells(r, c).Orientation
.Font.Size = WS.Cells(r, c).Font.Size
.HorizontalAlignment = WS.Cells(r, c).HorizontalAlignment
.VerticalAlignment = WS.Cells(r, c).VerticalAlignment
.MergeCells = WS.Cells(r, c).MergeCells
.Font.FontStyle = WS.Cells(r, c).Font.FontStyle
.Font.Name = WS.Cells(r, c).Font.Name
.ShrinkToFit = WS.Cells(r, c).ShrinkToFit
.NumberFormat = WS.Cells(r, c).NumberFormat
End With
Next
Next
这将解决大多数格式化的;根据需要添加其他单元格属性。
你用什么方法将表单复制到新文件中? – 2013-04-29 11:43:48
对于第一本书中的每张纸,我检查名称是否与数组匹配。如果是,我使用方法.copy。 – 2013-04-29 12:01:19
将您现有的代码添加到您的问题中 – 2013-04-29 12:03:50