출처: http://answers.google.com/answers/threadview/id/737271.html
여러 Sheet에 나뉘어져 있는 데이터들을 합계를 내거나 평균을 내는 등 통계 처리를 해야할 경우에 사용 가능한 Visual Basic for Application 입니다.
여러 시트에 있는 값을 읽어오기 위해서는 Sheets().Range()를 쓰면 됩니다.
다음은 출처에 나와있던 VBA 예제 코드 입니다.
여러 Sheet에 나뉘어져 있는 데이터들을 합계를 내거나 평균을 내는 등 통계 처리를 해야할 경우에 사용 가능한 Visual Basic for Application 입니다.
여러 시트에 있는 값을 읽어오기 위해서는 Sheets().Range()를 쓰면 됩니다.
다음은 출처에 나와있던 VBA 예제 코드 입니다.
Sub MakeSummary()
'
' MakeSummary Macro
' Macro created 6/12/2006 by Maniac
'
'
Sheets("SUMMARY").Select
' Clear the existing values (if any)
Range("$A$2:$D$60").Value = ""
' J tracks the row number on the summary page
' I tracks the sheet number being processed
J = 2
For I = 2 To Sheets.Count
A$ = Sheets(I).Name
' Don't process a sheet if its name is "Conversion Table"
' or if the name is blank.
If (A$ = "Conversion Table") Then GoTo 10
If (Sheets(A$).Range("$C$1").Value = "") Then GoTo 10
' Process the current sheet
Range("A" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R1C3"
Range("B" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R2C3"
Range("C" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R37C8"
Range("D" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R38C8"
J = J + 1
10 Next I
End Sub
'
' MakeSummary Macro
' Macro created 6/12/2006 by Maniac
'
'
Sheets("SUMMARY").Select
' Clear the existing values (if any)
Range("$A$2:$D$60").Value = ""
' J tracks the row number on the summary page
' I tracks the sheet number being processed
J = 2
For I = 2 To Sheets.Count
A$ = Sheets(I).Name
' Don't process a sheet if its name is "Conversion Table"
' or if the name is blank.
If (A$ = "Conversion Table") Then GoTo 10
If (Sheets(A$).Range("$C$1").Value = "") Then GoTo 10
' Process the current sheet
Range("A" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R1C3"
Range("B" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R2C3"
Range("C" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R37C8"
Range("D" + Format(J)).FormulaR1C1 = "='" + A$ + "'!R38C8"
J = J + 1
10 Next I
End Sub
'Office > Excel' 카테고리의 다른 글
"정의된 이름으로 저장된 Excel 4.0 함수입니다." 경고 메시지 해결 방법 (0) | 2015.04.20 |
---|---|
Excel에서 Extrapolation 하기 (0) | 2012.06.07 |
한 셀의 특정 문자의 갯수를 세는 VBA (0) | 2012.01.02 |
영역에서 특정 문구를 포함한 셀의 갯수 찾기 (0) | 2011.03.29 |
Excel Uniq 행 골라내기 (0) | 2011.02.27 |