Windows

엑셀 셀 서식 깨졌을때

Naan 2017. 2. 16. 12:14
반응형

엑셀 셀 서식 깨졌을때 하는 방법이다.


깨지는 증상은 낮은 버전의 서식은 상위 버전에 존재 하지 않아서 깨지는(?) 증상이다.

 

위 이미지를 보면 셀서식이 깨져 있다.

ALT + F11 를 누르면 visual basic for applications 이 구동된다.

 

 

위와 같이 개체에 마우스 오른쪽 눌러서 삽입 모듈을 선택한다.

 

 

위와 같이 그러면 코드 입력하는 화면이 뜨는데

 

아래 코드를 입력하자

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

 

입력하고 F5를 눌러서 스크립트를 실행해 주자.

 

 

실행해주면 모듈이라는게 생기는데 이걸 삭제 해주고

 

저장하자

 

그럼 위 이미지 처럼 서식이 정상적으로 나온다.

반응형

'Windows' 카테고리의 다른 글

msvcp140.dll 에러  (0) 2017.02.21
Outlook 메일 회수하기  (0) 2017.02.17
jira smtp setting for office 365  (0) 2017.02.15
smtp 인증 테스트 방법  (0) 2017.02.14
sticky note 수동 백업방법  (0) 2017.01.31