Hello everybody,
In the following code I call a series of if statements again and again under different conditions. For example I have highlighted one set of those if statements. They are repeated again and again in the code under different if conditions. Is there a way to write a seperate function for this and call it ? Is thee an efficient way to write these statements ?
In the following code I call a series of if statements again and again under different conditions. For example I have highlighted one set of those if statements. They are repeated again and again in the code under different if conditions. Is there a way to write a seperate function for this and call it ? Is thee an efficient way to write these statements ?
Rich (BB code):
LastRow = Sheets(2).UsedRange.Rows.count
For iCell = 2 To LastRow
If Sheets(2).Range("B" & iCell).Value <> Sheets(2).Range("B" & (iCell - 1)).Value Then
If Sheets(2).Range("E" & iCell).Value > 0 Then
If Sheets(2).Range("E" & iCell).Value <= Sheets(2).Range("K" & iCell).Value Then
O_FullCov = O_FullCov + 1
If Sheets(2).Range("C" & iCell).Value > 0.75 Then
Sheets(1).Range("D24").Value = Sheets(1).Range("D24").Value + 1
End If
If Sheets(2).Range("C" & iCell).Value <= 0.75 Then
If Sheets(2).Range("C" & iCell).Value > 0.5 Then
Sheets(1).Range("E24").Value = Sheets(1).Range("E24").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0.25 Then
If Sheets(2).Range("C" & iCell).Value <= 0.5 Then
Sheets(1).Range("F24").Value = Sheets(1).Range("F24").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0 Then
If Sheets(2).Range("C" & iCell).Value <= 0.25 Then
Sheets(1).Range("G24").Value = Sheets(1).Range("G24").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value = 0 Then
Sheets(1).Range("H24").Value = Sheets(1).Range("H24").Value + 1
End If
ElseIf Sheets(2).Range("I" & iCell).Value = 0 Then
O_NoCov = O_NoCov + 1
If Sheets(2).Range("C" & iCell).Value > 0.75 Then
Sheets(1).Range("D28").Value = Sheets(1).Range("D28").Value + 1
End If
If Sheets(2).Range("C" & iCell).Value <= 0.75 Then
If Sheets(2).Range("C" & iCell).Value > 0.5 Then
Sheets(1).Range("E28").Value = Sheets(1).Range("E28").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0.25 Then
If Sheets(2).Range("C" & iCell).Value <= 0.5 Then
Sheets(1).Range("F28").Value = Sheets(1).Range("F28").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0 Then
If Sheets(2).Range("C" & iCell).Value <= 0.25 Then
Sheets(1).Range("G28").Value = Sheets(1).Range("G28").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value = 0 Then
Sheets(1).Range("H28").Value = Sheets(1).Range("H28").Value + 1
End If
Else
O_SomeCov = O_SomeCov + 1
If Sheets(2).Range("C" & iCell).Value > 0.75 Then
Sheets(1).Range("D26").Value = Sheets(1).Range("D26").Value + 1
End If
If Sheets(2).Range("C" & iCell).Value <= 0.75 Then
If Sheets(2).Range("C" & iCell).Value > 0.5 Then
Sheets(1).Range("E26").Value = Sheets(1).Range("E26").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0.25 Then
If Sheets(2).Range("C" & iCell).Value <= 0.5 Then
Sheets(1).Range("F26").Value = Sheets(1).Range("F26").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value > 0 Then
If Sheets(2).Range("C" & iCell).Value <= 0.25 Then
Sheets(1).Range("G26").Value = Sheets(1).Range("G26").Value + 1
End If
End If
If Sheets(2).Range("C" & iCell).Value = 0 Then
Sheets(1).Range("H26").Value = Sheets(1).Range("H26").Value + 1
End If
End If