Download presentation
Presentation is loading. Please wait.
1
백업 PC에서 데이터 불러오기 (VBA 코드)
Private Sub auto_open() Dim 날짜 As Date Dim 시간$ Sheets(1).Select ActiveSheet.Unprotect 날짜 = DateValue(Year(Now - 1) & "-" & Month(Now - 1) & "-01") 시간 = " 오후 1:00:00" Call Main(날짜, 시간) 날짜입력.Show ActiveSheet.Protect End Sub Sub Main(ByRef 날짜, ByRef 시간) Dim 태그() Dim 새날짜 As Date Dim i% Dim j% ' 날짜 보정용... 태그 = Array("0FIQ901:count", "0PIT901:av", "0TI901:av", "0FIQ908:count") Application.ScreenUpdating = 0 [C2] = Year(날짜) & "년 " & Month(날짜) & "월 증기 판매 공급량" [5:38].ClearContents [5:35].EntireRow.Hidden = 1 [A37] = "합 계" [A38] = "평 균" i = 0: j = '24시간은 00시간과 같으므로 줄이기 위한 변수 On Error Resume Next Do While Month(날짜) = Month(날짜 + i) 새날짜 = 날짜 + i + j & 시간 If 새날짜 > Now Then Exit Do Rows(i + 5 & ":" & i + 5).EntireRow.Hidden = 0 [A5].Offset(i, 0) = Format(날짜 + i, "yyyy-mm-dd") If 날짜입력.OptionButton1 = True Then [B5].Offset(i, 0) = "24:00" j = 1 Else [B5].Offset(i, 0) = "13:00" End If [C5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(0) & ""","""","""",""" & 날짜 i + j & 시간 & """,1040, 0, 0, 0 )" [D5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(0) & ""","""","""",""" & 날짜 + i + j & 시간 & """,1040, 0, 0, 0 )" [E5].Offset(i, 0) = 0 '[D5].Offset(i, 0).Value - [C5].Offset(i, 0).Value If i = 0 Then [F5] = [E5] [F5].Offset(i, 0) = [F5].Offset(i - 1, 0) + [E5].Offset(i, 0) [G5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(1) & ""","""","""",""" & 날짜 + i + j & 시간 & """,1040, 0, 0, 0 )" [H5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(2) & ""","""","""",""" & 날짜 + i + j & 시간 & """,1040, 0, 0, 0 )" [I5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(3) & ""","""","""",""" & 날짜 i + j & 시간 & """,1040, 0, 0, 0 )" [J5].Offset(i, 0) = "=ATGetTimeVal(""" & 태그(3) & ""","""","""",""" & 날짜 + i + j & 시간 & """,1040, 0, 0, 0 )" [K5].Offset(i, 0) = 0 ' [J5].Offset(i, 0) - [I5].Offset(i, 0) Worksheets("증기판매").Rows(5 + i).Copy Worksheets("증기판매").Cells(5 + i, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone Application.CutCopyMode = False i = i + 1 Loop [B37] = i [C37] = [C5] [D37] = "=Max(R[-32]C:R[-2]C)" [F37] = [D37] - [C37] [I37] = [I5] [J37] = "=Max(R[-32]C:R[-2]C)" [K37] = [J37] - [I37] [E38] = [F37] / i [K38] = [K37] / i Calculate Application.ScreenUpdating = 1 [B2].Select Private Sub Auto_close() ActiveWorkbook.Close (0) Private Sub 날짜입력창() Private Sub 인쇄() ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ IgnorePrintAreas:=False Private Sub 도움() 도움말.Show
Similar presentations