Public Sub Collect_Books_From_G()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
CurrentName = ThisWorkbook.Name
StrPath = Workbooks(CurrentName).Sheets("Datas").Cells(4, 2).Value '2013.5.13 NE’ljÁ
NameCnt = Sheets("WillEmpList").Range("B1").CurrentRegion.Rows.Count
CopyOKCnt = 3
BookEmptyCnt = 3
NoWillCnt = 3
DateNum = Format(Now, "yyyy/mm/dd hh:mm")
Sheets("Summary").Range("N2") = DateNum
StrMonth = Workbooks(CurrentName).Sheets("Datas").Range("B1")
For i = 2 To NameCnt
StrFileFolder = Workbooks(CurrentName).Sheets("WillEmpList").Range("F" & i)
StrFileName = Workbooks(CurrentName).Sheets("WillEmpList").Range("H" & i)
StrFileAll = StrPath & StrFileFolder & "\Will_Book" & StrFileName & "_" & StrMonth & ".xls"
StrFileNAMAE = "Will_Book" & StrFileName & "_" & StrMonth & ".xls"
StrName = Workbooks(CurrentName).Sheets("WillEmpList").Range("B" & i)
StrNum = Workbooks(CurrentName).Sheets("WillEmpList").Range("F" & i)
NextRowB = Workbooks(CurrentName).Sheets("Summary").Range("B65536").End(xlUp).Row + 1
NextRowG = Workbooks(CurrentName).Sheets("Summary").Range("G65536").End(xlUp).Row + 1
NextRow = NextRowB
If NextRow < NextRowG Then NextRow = NextRowG
If Dir(StrFileAll) <> "" Then
Application.EnableEvents = False
Workbooks.Open (StrFileAll), UpdateLinks:=0, ReadOnly:=True
Application.EnableEvents = True
Set FSO = CreateObject("Scripting.FileSystemObject")
StrLastTime = FSO.GetFile(StrFileAll).DateLastModified
Set FSO = Nothing
Windows(StrFileNAMAE).Activate
Sheets("Income").Select
If Sheets("Income").Range("A2") = "" And Sheets("Income").Range("B2") = "" And Sheets("Income").Range("C2") = "" And _
Sheets("Income").Range("D2") = "" And Sheets("Income").Range("E2") = "" And Sheets("Income").Range("F2") = "" And _
Sheets("Income").Range("G2") = "" And Sheets("Income").Range("H2") = "" And Sheets("Income").Range("I2") = "" And _
Sheets("Income").Range("J2") = "" And Sheets("Income").Range("K2") = "" And Sheets("Income").Range("L2") = "" Then
Workbooks(CurrentName).Sheets("Summary").Range("O" & BookEmptyCnt) = StrName & "-" & StrNum
BookEmptyCnt = BookEmptyCnt + 1
Else
With Sheets("Income")
.Range("B65536").End(xlUp).Select
RowB = Selection.Row
.Range("H65536").End(xlUp).Select
RowG = Selection.Row
RowCnt = RowB
If RowCnt < RowG Then RowCnt = RowG
Workbooks(CurrentName).Sheets("Summary").Activate
Workbooks(CurrentName).Sheets("Summary").Range("A" & NextRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.Save
End With
Workbooks(CurrentName).Sheets("Summary").Range("P" & CopyOKCnt) = StrName & "-" & StrNum
Workbooks(CurrentName).Sheets("Summary").Range("O" & CopyOKCnt) = StrLastTime
CopyOKCnt = CopyOKCnt + 1
End If
Excel.Application.CutCopyMode = False
Workbooks(StrFileNAMAE).Close SaveChanges:=False
Else
Workbooks(CurrentName).Sheets("Summary").Range("R" & NoWillCnt) = StrName & "-" & StrNum
NoWillCnt = NoWillCnt + 1
End If
Next
Range("A2").Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Visible = True
Excel.Application.CutCopyMode = True
End Sub
Bookmarks