爲了保留源工作表的原始格式使用下面的:
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