2016-09-19 5 views
0

현재 작업 (작업 중 하나)은 다른 스타일의 동일한 스타일, 동일한 형식을 다른 Excel 파일에 적용하는 것과 관련되어 있습니다.엑셀, 다른 엑셀 파일에 스타일 시트 적용

나는 그것을 단순화하는 방법을 찾고 싶다.

이 스타일 시트 (또는 일종의 생각)가 필요합니다.

1) Add empty line to very top of the excel file 
2) A1-F2 make bold 
3) A1-F3 Make full borders 
4) A1-F3 Auto Fit Column Width 
5) A2-F2 Make colour GREY 

매일 많은 양의 파일에 동일한 스타일을 적용해야합니다. 앞으로도 간단한 솔루션을 기대합니다.

+0

Excel 파일은 통합 문서입니다. 통합 문서는 여러 워크 시트를 포함 할 수 있습니다. 어떤 워크 시트 당신이 맨 위에 빈 행을 추가하면? 서식을 업데이트 한하고자 할, 1 행은 비어 있습니다. 왜 매일 업데이트 할 통합 문서를 어떻게 알 수 있습니까? 해당 요구 사항을 충족하기 위해 코드를 만들기 전에 회사 요구 사항을 고려해야한다고 생각합니다. –

+0

아래 @Bob Moshon 코드에서 한 시트를 포맷합니다. –

답변

1

매크로 레코더를 사용하여 시작할 수 있습니다.

어쨌든, 아래의 코드를 시도 (이것은 "시트 1"() 요청한 시트 이름에 수정을 위해 포맷됩니다.

을 모든 시트에 적용 할 경우에, 당신은 모든 시트를 통해 루프 필요 통합 문서.

Option Explicit 

Sub ApplyExcelShtFormat() 

Dim Sht    As Worksheet 

' change Sheet name to your needs 
Set Sht = ThisWorkbook.Sheets("Sheet1") 

With Sht 
    ' add 1 Row above the first row 
    .Rows("1:1").Insert Shift:=xlDown 

    ' modify font to bold 
    .Range("A1:F2").Font.Bold = True 

    ' add borders all around 
    .Range("A1:F3").BorderAround xlContinuous, xlThin 

    ' add internal borders 
    With .Range("A1:F3").Borders(xlInsideVertical) 
     .LineStyle = xlContinuous 
     .Weight = xlThin 
    End With 
    With .Range("A1:F3").Borders(xlInsideHorizontal) 
     .LineStyle = xlContinuous 
     .Weight = xlThin 
    End With 

    ' columns auto fit 
    .Range("A1:F3").EntireColumn.AutoFit 

    ' cell interior color grey (change number according to your kind of gray) 
    .Range("A2:F2").Interior.Color = 9868950 
End With 

End Sub