I have a Macro that calculates Values in a Range depending on their existence. If all exist then perform a certain calculation else it goes through a variations of multiple conditions and calculates according to what exist. I am so far able to get it to calculate if all values exist but not the variations of some not existing. Any assistance would be greatly appreciated. (see code below)

Option Explicit
Private Sub example()

Dim ws As Worksheet
Dim s As Range
Dim lastcol as Long
Dim lastrow as Long
Dim h1 As Variant
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String

lastcol = ws.Cells(4, Columns.Count).End(xlToLeft).Column
lastrow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
On Error Resume Next

h1 = ws.Range("A4:Z4").Find("Header1").Offset(1, 0).Address(False, False)
'h2 to h6 - same as above

a = "Header1"
b = "Header2"
c = "Header3"
d = "Header4"
e = "Header5"

ws.Range(Range("A4:Z4").Find("Header0").Offset(0, 1), Range("A4:Z4").Find("Header6").Offset(0, -1)).Select
With Selection
For Each s In Selection

        'Calc (Header1, Header2, Header3, Header4, Header5) - ALL
If s.Value.a = True And s.Value.b = True And s.Value.c = True And s.Value.d = True And s.Value.e = True Then
ws.Range(Range("A4:Z4").Find("Result %").Offset(1, 0), Cells(lastrow, lastcol)).Formula = _
"=IFERROR(SUM(" & h1 & "," & h2 & "," & h3 & "," & h4 & ", If(" & h5 & "/" & h6 & ">1%," & h6 & "*1%," & h5 & "))/ " & h6 & ", """") "

    'Calc (Header1, Header2, Header3, Header4) - NO Header5
ElseIf s.Value.a = True And s.Value.b = True And s.Value.c = True And s.Value.d = True And s.Value.e = False Then
ws.Range(Range("A4:Z4").Find("Result %").Offset(1, 0), Cells(lastrow, lastcol)).Formula = _
"=IFERROR(SUM(" & h1 & "," & h2 & "," & h3 & "," & h4 & ")/" & h6 & ", """") "

    'Calc (Header1, Header2, Header3, Header5) - NO Header4
ElseIf s.Value.a = True And s.Value.b = True And s.Value.c = True And s.Value.d = False And s.Value.e = True Then
ws.Range(Range("A4:Z4").Find("Result %").Offset(1, 0), Cells(lastrow, lastcol)).Formula = _
"=IFERROR(SUM(" & h1 & "," & h2 & "," & h3 & ", IF(" & h5 & "/" & h6 & ">1%," & h6 & "*1%," & h5 & "))/" & h6 & ", """") " ' Total of 15 conditions and formulas

End If
Next
End With
End Sub