Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter code here
- OrigRowHeight = SafeRange.RowHeight
- OrigColWidth = SafeRange.ColumnWidth
- CurRow = ActiveCell.Row
- CurCol = ActiveCell.Column
- NumMergeCols = ActiveCell.MergeArea.Count
- LastCol = CurCol + NumMergeCols - 1
- For i = CurCol To LastCol
- CombinedColWidth = CombinedColWidth + Cells(CurRow, i).ColumnWidth
- Next i
- ' Most of the following code came from Superuser user6261023 (My Thanks)
- With SafeSheet.Range(SafeRange.Address)
- TargetRange.Copy
- .PasteSpecial xlPasteAll
- .UnMerge
- .ColumnWidth = CombinedColWidth
- .Value = TargetRange.Value
- .EntireRow.AutoFit
- NeededRowHeight = 1.05 * .RowHeight / TargetRange.MergeArea.Rows.Count
- .ClearContents
- .ClearFormats
- .RowHeight = OrigRowHeight
- .ColumnWidth = OrigColWidth
- End With
- 'Return NeededRowHeight
- NewRowHeight = NeededRowHeight
- OrigRowHeight = SafeRange.RowHeight
- OrigColWidth = SafeRange.ColumnWidth
- CurRow = ActiveCell.Row
- CurCol = ActiveCell.Column
- NumMergeCols = ActiveCell.MergeArea.Count
- LastCol = CurCol + NumMergeCols - 1
- For i = CurCol To LastCol
- CombinedColWidth = CombinedColWidth + Cells(CurRow, i).ColumnWidth
- Next i
- ' Most of the following code came from Superuser user6261023 (My Thanks)
- With SafeSheet.Range(SafeRange.Address)
- TargetRange.Copy
- .PasteSpecial xlPasteAll
- .UnMerge
- .ColumnWidth = CombinedColWidth
- .Value = TargetRange.Value
- .EntireRow.AutoFit
- NeededRowHeight = 1.05 * .RowHeight / TargetRange.MergeArea.Rows.Count
- .ClearContents
- .ClearFormats
- .RowHeight = OrigRowHeight
- .ColumnWidth = OrigColWidth
- End With
- 'Return NeededRowHeight
- NewRowHeight = NeededRowHeight
Add Comment
Please, Sign In to add comment