728x90
반응형
Alt + F11
삽입-모듈
스크립트 입력
실행
Sub 이미지_세로정렬_간격5()
Dim ws As Worksheet
Dim shp As Shape
Dim pictureShapes() As Shape
Dim count As Integer
Dim i As Integer, j As Integer
Dim temp As Shape
Dim topPos As Single
Dim spacing As Single
Set ws = ActiveSheet
spacing = 5
count = 0
' 이미지 개수 세고 배열에 저장
For Each shp In ws.Shapes
If shp.Type = msoPicture Then
count = count + 1
ReDim Preserve pictureShapes(1 To count)
Set pictureShapes(count) = shp
End If
Next shp
' Y 좌표 기준으로 버블 정렬
For i = 1 To count - 1
For j = i + 1 To count
If pictureShapes(i).Top > pictureShapes(j).Top Then
Set temp = pictureShapes(i)
Set pictureShapes(i) = pictureShapes(j)
Set pictureShapes(j) = temp
End If
Next j
Next i
' 정렬 및 위치 재배치
topPos = 10
For i = 1 To count
With pictureShapes(i)
.Top = topPos
.Left = Range("A1").Left
topPos = topPos + .Height + spacing
End With
Next i
End Sub
728x90
반응형
'배움 - 차근차근 기록하자 > [정보] 업무 🟡' 카테고리의 다른 글
[CMD] 쉽게 빈 폴더 삭제하는 법 (0) | 2022.04.15 |
---|---|
[아웃룩] 첨부파일 일괄 다운로드 (1) | 2022.04.15 |
[MIL] Matrox Mil10 완전 삭제 방법 (CleanMil64)-프로그램 공유 (0) | 2022.04.15 |
[비주얼스튜디오] dll 의존성 검사 (어떤 dll들이 필요하지?) (0) | 2021.12.22 |