매크로를 쓰는 자세한 방법은 문서 맨 아래 링크를 참고하세요 :)
지금 워크시트에 적혀있는 모든 메모를, 적절한 위치와 크기로 변환해줍니다.
- 너무 멀리 떨어져 있거나, 크기가 너무 작아서 안보이는 메모들을 편하게 한번에 바꿔줍니다.
=========아래를 붙여넣기 하세요==========
Sub Reset_Autosize_Comments()
Dim cmt As Comment
'1 pixel = 0.75 points (for comment)
'64 pixels = 8.43 characters, but column width/characters cannot be specified by arithmetic operations
'Empty cell selection
Set Empty_cell = Application.InputBox(prompt:="아무것도 없는 빈 셀을 선택해주세요.", Type:=8)
Column_width = Range(Empty_cell.Address).ColumnWidth
Range(Empty_cell.Address).Font.Size = "9" 'Typical Comment Font Size
Range(Empty_cell.Address).Font.Name = "Tahoma" 'Typical Comment Font Name
'Size adjustment
For Each cmt In ActiveSheet.Comments
With cmt
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 250 Then '150 points = 200 pixels
'#Route 1: Height calculation in A1 cell
Range(Empty_cell.Address).Value = cmt.Text
Range(Empty_cell.Address).ColumnWidth = 30.63 '27.86 characters = 200 pixels
Range(Empty_cell.Address).Rows.AutoFit
cmt_height = Range(Empty_cell.Address).Rows.Height
Range(Empty_cell.Address).Value = ""
'Re-size of comment
.Shape.Width = 187.5 '150 points = 200 pixels
.Shape.Height = cmt_height + 10
End If
End With
Next
'Empty cell recovery
Range(Empty_cell.Address).ColumnWidth = Column_width
'Position adjustment
For Each cmt In ActiveSheet.Comments
cmt.Shape.Top = cmt.Parent.Top + 5
cmt.Shape.Left = cmt.Parent.Offset(0, 1).Left + 5
Next
End Sub
===============================
'5. VBA,매크로' 카테고리의 다른 글
[엑셀 매크로/VBA] 이름을 모두 삭제 (0) | 2020.04.10 |
---|---|
[엑셀 매크로/VBA] 매크로 코드를 실행하는 법 (0) | 2020.04.10 |
[엑셀 매크로/VBA] 스타일을 모두 삭제 (0) | 2020.04.02 |
[엑셀 매크로/VBA] 빈 칸이 끝날때까지 세로로 채워넣기 (0) | 2020.04.02 |
[엑셀 매크로/VBA] 적혀있는 모든 메모를 요약 (0) | 2020.04.02 |