I wrote a script to copy sheet by sheet from ThisWorkbook to another workbook. Everything seems to work fine except for the column width of the last sheet, and only the last sheet. Some columns have wrapped text which is not found in the original. I eliminated most of the code and only copied formats and column widths. Still, the column widths are different from that in the original file. And this only happens with the last sheet.
Sub copy_all()
Dim rng As Range
Dim i As Integer
Dim destBook As Workbook
Set destBook = Workbooks("Book3")
With destBook
For i = 1 To ThisWorkbook.Sheets.Count
Set rng = ThisWorkbook.Sheets(i).UsedRange
rng.Copy
.Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteFormats
.Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteColumnWidths
Next i
End With
End Sub
I even wrote a script to list the column widths of the original and copied files so it'd easy to compare. Indeed, only the last page of the column widths are different. All the other 13 pairs of pages of the original and copied files have the identical column widths.
As you can see from the following picture, only some of the column width on the last page are different from the original, not every one of them. Some are identical to the original. Only those with a width of 87 are copied to becoming a width of 48.
My question is what is wrong with the copy script? Thanks in advance for any help.