dhn46
Hướng tới tương lai
- Tham gia
- 1/3/11
- Bài viết
- 3,251
- Được thích
- 3,870
Thiếu 1 end if anh ah. Anh thay thế đoạn sau nhé
Mã:
'Find the date in the target file
ActiveWorkbook.Worksheets(1).Unprotect ("smiles")
Set Fdate = Worksheets(1).[B2:B65536] _
.Find(Dt, LookIn:=xlFormulas, LookAt:=xlWhole)
If Fdate Is Nothing Then
'If not Exists date then add new line
Set vTarget = Worksheets(1).[A65536].End(3)
vTarget.Offset(1, 0) = Val(vTarget) + 1
vTarget.Offset(1, 1) = Dt
vTarget.Offset(1, 2) = CustomerService
vTarget.Offset(1, 3) = BusinessProcess
vTarget.Offset(1, 4) = Compliance
vTarget.Offset(1, 5) = ProfessionalApproach
vTarget.Offset(1, 6) = LabourEfficiencies
vTarget.Offset(1, 7) = (CustomerService + BusinessProcess + Compliance + ProfessionalApproach + LabourEfficiencies) / 5
vTarget.Offset(1, 8) = user
Else
If Fdate.Offset(0, 1) <> user Then
'If exists date then Update
'If not User
Fdate.Offset(0, 1) = CustomerService
Fdate.Offset(0, 2) = BusinessProcess
Fdate.Offset(0, 3) = Compliance
Fdate.Offset(0, 4) = ProfessionalApproach
Fdate.Offset(0, 5) = LabourEfficiencies
Fdate.Offset(0, 6) = (CustomerService + BusinessProcess + Compliance + ProfessionalApproach + LabourEfficiencies) / 5
Fdate.Offset(0, 7) = user
Else
Set vTarget = Worksheets(1).[A65536].End(3)
vTarget.Offset(1, 0) = Val(vTarget) + 1
vTarget.Offset(1, 1) = Dt
vTarget.Offset(1, 2) = CustomerService
vTarget.Offset(1, 3) = BusinessProcess
vTarget.Offset(1, 4) = Compliance
vTarget.Offset(1, 5) = ProfessionalApproach
vTarget.Offset(1, 6) = LabourEfficiencies
vTarget.Offset(1, 7) = (CustomerService + BusinessProcess + Compliance + ProfessionalApproach + LabourEfficiencies) / 5
End If
End If
ActiveWorkbook.UsedRange.Border.LineStyle = xlThin
Columns("A:I").EntireColumn.AutoFit
Columns("A:I").HorizontalAlignment = xlCenter
ActiveWorkbook.Worksheets(1).Protect ("smiles")
.Close SaveChanges:=True
End With