20220510 1224
REF
[1] "https://docs.microsoft.com/en-us/office/vba/api/office.msoautoshapetype"
[2] "https://docs.microsoft.com/en-us/office/vba/api/excel.textframe"
[3] "https://www.codevba.com/Excel/TextFrame/HorizontalAlignment.htm#.Yn3Ms-jMJaQ"
1, 타원 그리기
Sub zMakeOval()
Dim shp1 As Shape
For i = 1 To Selection.Areas.Count
x1 = Selection.Areas.Item(i).Left
w1 = Selection.Areas.Item(i).Width
y1 = Selection.Areas.Item(i).Top
h1 = Selection.Areas.Item(i).Height
Set shp1 = ActiveSheet.Shapes.AddShape(msoShapeOval, x1, y1, w1, h1)
shp1.Fill.Visible = msoFalse 'unfill the interior of boxes
Next i
End Sub
2, 사각형 그리기
Sub zMakeBoxes() Dim shp1 As Shape For i = 1 To Selection.Areas.Count x1 = Selection.Areas.Item(i).Left w1 = Selection.Areas.Item(i).Width y1 = Selection.Areas.Item(i).Top h1 = Selection.Areas.Item(i).Height '''add box Set shp1 = ActiveSheet.Shapes.AddShape(msoShapeRectangle, x1, y1, w1, h1) shp1.Fill.Visible = msoFalse 'unfill the interior of boxes Next i End Sub |
a, 모서리가 둥근 사각형 ; msoShapeRoundedRectangle 또는 5
3, 모서리 둥근 사각형 그리고 선택된 셀의 값(문자)을 표시하기
a, 도형에 문자를 넣을 수도 있다 [2]
Sub zMakeBoxes() Dim sh1 As Shape For i = 1 To Selection.Areas.Count x1 = Selection.Areas.Item(i).Left w1 = Selection.Areas.Item(i).Width y1 = Selection.Areas.Item(i).Top h1 = Selection.Areas.Item(i).Height '''add box Set sh1 = ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, x1, y1, w1, h1) 'sh1.Fill.Visible = msoFalse 'unfill the interior of boxes sh1.TextFrame.Characters.Text = Selection.Areas(i).Value sh1.TextFrame.HorizontalAlignment = xlHAlignCenter sh1.TextFrame.VerticalAlignment = xlVAlignCenter Next i End Sub |
'[PA] 업무자동화 > [XL]Excel & VBA' 카테고리의 다른 글
XL LAMBDA function 람다 함수 (0) | 2022.05.13 |
---|---|
XL 탭 효과 tab effect (0) | 2022.05.13 |
XL Personal.xlsb Macro (0) | 2022.05.10 |
XL Ribbon menu - customize, add, export (0) | 2022.05.10 |
XL draw a line between two cells (0) | 2022.05.10 |