Как макросом скопировать ширину и высоту ячеек активного листа на все остальные листы ? На активном листе имеются объединеные ячейки
Спасибо
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ActiveSheet: ws1.Cells.Copy
For Each ws2 In ActiveWorkbook.Worksheets
If Not ws1 Is ws2 Then ws2.Cells.PasteSpecial xlPasteFormats 'xlPasteColumnWidths
Next
Application.CutCopyMode = False
Sub Test()
Dim colHeight As New Collection
Dim colWidth As New Collection, i As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim rSource As Range, rTemp As Range
Set ws1 = ActiveWorkbook.ActiveSheet
Set rSource = ws1.Range(ws1.Cells(1), ws1.UsedRange)
For Each rTemp In rSource.Rows
colHeight.Add rTemp.RowHeight
Next
For Each rTemp In rSource.Columns
colWidth.Add rTemp.ColumnWidth
Next
For Each ws2 In ActiveWorkbook.Worksheets
If Not (ws2 Is ws1) Then
For i = 1 To colHeight.Count
ws2.Rows(i).RowHeight = colHeight(i)
Next
For i = 1 To colWidth.Count
ws2.Columns(i).ColumnWidth = colWidth(i)
Next
End If
Next
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7