안녕하세요? [다우리]님...
구체적인 에제가 없어 코드로만 답변드리겠습니다.
(파일을 첨부하시고자 하면 카페의 묻고답하기(파일첨부) 게시판을 이용하시면 좀더 구체적인 답변을 받으실 수 있습니다.)
현재 드리는 코드의 파일이 예를들어 c:\abc\ 폴더에 있다고 가정하면...
순환하고자 하는 엑셀 파일들은 c:\abc\data\ 폴더에 있다고 가정합니다.
c:\abc\ 폴더에 VBA포함 xlsm 파일을 하나 만들고 아래 코드를 복사해 사용해 보세요.
(참고로 전력량은 구체적 언급이 없어 어찌 계산되는지 몰라 텍스트로 입력했으니
응용해서 해결해 보세요.)
Sub Test()
Dim strFile As String, PS As String
Dim VarData(0, 3) As Variant
Dim strPath As String
PS = Application.PathSeparator
strPath = ThisWorkbook.Path & PS & "DATA" & PS
strFile = Dir(strPath & "*.xls*")
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
Do While strFile <> ""
If strFile <> ThisWorkbook.Name Then
Workbooks.Open strPath & strFile
With ActiveWorkbook.ActiveSheet
VarData(0, 0) = Left(strFile, 8)
VarData(0, 1) = .Range("e1430")
VarData(0, 2) = .Range("e2")
VarData(0, 3) = "어찌 계산되는지???"
End With
ActiveWorkbook.Close
Sheet1.Cells(Rows.Count, "a").End(xlUp).Offset(1).Resize(1, 4).Value = VarData
Erase VarData
strFile = Dir
End If
Loop
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
MsgBox "모든 데이터 가져오기 완료...!", vbInformation, "엑셀전문가클럽(cafe.daum.net/funnyexcel)"
End Sub
그럼 잘 해결되시길... ^^*
첫댓글 오늘도 좋은 하루... ^^*