표준스타일을 제외한 모든 스타일을 제거하는 매크로 함수
모듈에 아래 함수를 만들고
매크로로 지정하면....끝.
Sub RebuildDefaultStyles()
'The purpose of this macro is to remove all styles in the active
'workbook and rebuild the default styles. "Normal" cannot be
'deleted. Therefore the macro does not attempt to delete it.
'It rebuilds the default styles by merging them from a new workbook.
'Dimension variables. // 변수선언
Dim MyBook As Workbook
Dim tempBook As Workbook
Dim CurStyle As Style
On Error Resume Next '//오류가 발생하도 무시하고 계속 진행
'Set MyBook to the active workbook.
Set MyBook = ActiveWorkbook
'Delete all the styles in the workbook.
For Each CurStyle In ActiveWorkbook.Styles
If Not (CurStyle.BuiltIn) Then CurStyle.Delete '//기본 스타일이 아닐 경우에만 삭제
Next CurStyle
'Open a new workbook.
Set tempBook = Workbooks.Add
'Disable alerts so you may merge changes to the Normal style
'from the new workbook.
Application.DisplayAlerts = False
'Merge styles from the new workbook into the existing workbook.
MyBook.Styles.Merge Workbook:=tempBook
'Enable alerts.
Application.DisplayAlerts = True
'Close the new workbook.
tempBook.Close
End Sub
'공사 > EXCEL & VBA' 카테고리의 다른 글
조건부 서식 전체삭제 (0) | 2016.03.25 |
---|---|
데이터유효성검사를 이용한 드롭다운 메뉴 항목 만들기 (0) | 2013.07.11 |
문자열 내 특정 글자 바꾸기 (0) | 2013.07.03 |
문자열을 구분자를 이용한 1차원 배열화 (0) | 2013.06.21 |
엑셀 차트 이름바꾸기 (0) | 2013.05.10 |