Sub AddDataShort(LA As String, BisName As String, BisID As String, DOI As Date, Scope As String, FHS As Variant, FHSNA As Variant, CCP As Variant, CCPNA As Variant, Structural As Variant, StructuralNA As Variant, Label As Variant, LabelNA As Variant, COMPOSITION As Variant, CompositionNA As Variant, FSMS As Variant, CIM As Variant, OptionGroup1 As Boolean, OptionGroup2 As Boolean, OptionGroup3 As Boolean, Comment As Variant, IntTime As Date, AdTime As Date)
Sheets("Data").Activate
Dim NextColumn As Integer
Dim AvgValue As Integer
Dim NextInt As Double
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
'Text Entry
NextColumn = 1
Cells(NextRow, NextColumn) = LA
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = BisName
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = BisID
NextColumn = NextColumn + 1
With Cells(NextRow, NextColumn)
.Value = DOI
.NumberFormat = "dd/mm/yy"
End With
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = Scope
NextColumn = NextColumn + 1
'Business Group
If OptionGroup1 Then Cells(NextRow, NextColumn) = 1
If OptionGroup2 Then Cells(NextRow, NextColumn) = 2
If OptionGroup3 Then Cells(NextRow, NextColumn) = 3
NextColumn = NextColumn + 1
'Food Hygiene and Systems
If FHS = ThisWorkbook.Sheets("EM").Range("A2").Value Then Cells(NextRow, NextColumn) = 5
If FHS = ThisWorkbook.Sheets("EM").Range("A3").Value Then Cells(NextRow, NextColumn) = 4
If FHS = ThisWorkbook.Sheets("EM").Range("A4").Value Then Cells(NextRow, NextColumn) = 3
If FHS = ThisWorkbook.Sheets("EM").Range("A5").Value Then Cells(NextRow, NextColumn) = 2
If FHS = ThisWorkbook.Sheets("EM").Range("A6").Value Then Cells(NextRow, NextColumn) = 1
If FHS = ThisWorkbook.Sheets("EM").Range("A7").Value Then Cells(NextRow, NextColumn) = 0
NextColumn = NextColumn + 1
'Cross Contamination
If CCP = ThisWorkbook.Sheets("EM").Range("B2").Value Then Cells(NextRow, NextColumn) = 5
If CCP = ThisWorkbook.Sheets("EM").Range("B3").Value Then Cells(NextRow, NextColumn) = 4
If CCP = ThisWorkbook.Sheets("EM").Range("B4").Value Then Cells(NextRow, NextColumn) = 3
If CCP = ThisWorkbook.Sheets("EM").Range("B5").Value Then Cells(NextRow, NextColumn) = 2
If CCP = ThisWorkbook.Sheets("EM").Range("B6").Value Then Cells(NextRow, NextColumn) = 1
If CCP = ThisWorkbook.Sheets("EM").Range("B7").Value Then Cells(NextRow, NextColumn) = 0
NextColumn = NextColumn + 1
'Structural Performance
If Structural = ThisWorkbook.Sheets("EM").Range("C2").Value Then Cells(NextRow, NextColumn) = 5
If Structural = ThisWorkbook.Sheets("EM").Range("C3").Value Then Cells(NextRow, NextColumn) = 4
If Structural = ThisWorkbook.Sheets("EM").Range("C4").Value Then Cells(NextRow, NextColumn) = 3
If Structural = ThisWorkbook.Sheets("EM").Range("C5").Value Then Cells(NextRow, NextColumn) = 2
If Structural = ThisWorkbook.Sheets("EM").Range("C6").Value Then Cells(NextRow, NextColumn) = 1
If Structural = ThisWorkbook.Sheets("EM").Range("C7").Value Then Cells(NextRow, NextColumn) = 0
NextColumn = NextColumn + 1
'Labelling Performance
If Label = ThisWorkbook.Sheets("EM").Range("D2").Value Then Cells(NextRow, NextColumn) = 5
If Label = ThisWorkbook.Sheets("EM").Range("D3").Value Then Cells(NextRow, NextColumn) = 4
If Label = ThisWorkbook.Sheets("EM").Range("D4").Value Then Cells(NextRow, NextColumn) = 3
If Label = ThisWorkbook.Sheets("EM").Range("D5").Value Then Cells(NextRow, NextColumn) = 2
If Label = ThisWorkbook.Sheets("EM").Range("D6").Value Then Cells(NextRow, NextColumn) = 1
If Label = ThisWorkbook.Sheets("EM").Range("D7").Value Then Cells(NextRow, NextColumn) = 0
NextColumn = NextColumn + 1
'Composition Preformance
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E2").Value Then Cells(NextRow, NextColumn) = 5
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E3").Value Then Cells(NextRow, NextColumn) = 4
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E4").Value Then Cells(NextRow, NextColumn) = 3
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E5").Value Then Cells(NextRow, NextColumn) = 2
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E6").Value Then Cells(NextRow, NextColumn) = 1
If COMPOSITION = ThisWorkbook.Sheets("EM").Range("E7").Value Then Cells(NextRow, NextColumn) = 0
NextColumn = NextColumn + 1
'Food Sayety Management System
If FSMS = ThisWorkbook.Sheets("EM").Range("F2").Value Then Cells(NextRow, NextColumn) = 5
If FSMS = ThisWorkbook.Sheets("EM").Range("F3").Value Then Cells(NextRow, NextColumn) = 4
If FSMS = ThisWorkbook.Sheets("EM").Range("F4").Value Then Cells(NextRow, NextColumn) = 3
If FSMS = ThisWorkbook.Sheets("EM").Range("F5").Value Then Cells(NextRow, NextColumn) = 2
If FSMS = ThisWorkbook.Sheets("EM").Range("F6").Value Then Cells(NextRow, NextColumn) = 1
NextColumn = NextColumn + 1
'Confidence in Management
If CIM = ThisWorkbook.Sheets("EM").Range("G2").Value Then Cells(NextRow, NextColumn) = 5
If CIM = ThisWorkbook.Sheets("EM").Range("G3").Value Then Cells(NextRow, NextColumn) = 4
If CIM = ThisWorkbook.Sheets("EM").Range("G4").Value Then Cells(NextRow, NextColumn) = 3
If CIM = ThisWorkbook.Sheets("EM").Range("G5").Value Then Cells(NextRow, NextColumn) = 2
If CIM = ThisWorkbook.Sheets("EM").Range("G6").Value Then Cells(NextRow, NextColumn) = 1
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = Comment
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = FHSNA
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = CCPNA
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = StructuralNA
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = LabelNA
NextColumn = NextColumn + 1
Cells(NextRow, NextColumn) = CompositionNA
NextColumn = NextColumn + 1
With Cells(NextRow, NextColumn)
.Value = IntTime
.NumberFormat = "hh:mm"
End With
NextColumn = NextColumn + 1
With Cells(NextRow, NextColumn)
.Value = AdTime
.NumberFormat = "hh:mm"
End With
NextColumn = NextColumn + 1
With Cells(NextRow, NextColumn)
.Value = AdTime + IntTime
.NumberFormat = "hh:mm"
End With
NextColumn = NextColumn + 1
AvgValue = Round(Application.WorksheetFunction.AverageIf(Range(Cells(NextRow, 7), Cells(NextRow, 13)), ">0"), 0)
NextInt = Application.WorksheetFunction.Index(EM.Range("A13:D18"), Application.WorksheetFunction.Match(AvgValue, EM.Range("A13:A18"), 0), Application.WorksheetFunction.Match(Cells(NextRow, 6), EM.Range("A13:D13"), 0)) '<-Error happens in this Row
With Cells(NextRow, NextColumn)
.Value = NextInt + DOI
.NumberFormat = "dd/mm/yy"
End With
End Sub
Bookmarks