Private
Sub
CommandButton1_Click()
Dim
ws
As
Worksheet
Set
ws = ThisWorkbook.Sheets(
"Auswertung einzeln"
)
If
ws
Is
Nothing
Then
MsgBox
"Das angegebene Arbeitsblatt wurde nicht gefunden."
Exit
Sub
End
If
Dim
vvocStart
As
String
, vvocEnd
As
String
Dim
vocStart
As
String
, vocEnd
As
String
Dim
svocStart
As
String
, svocEnd
As
String
vvocStart = TextBox1.Text
vvocEnd = TextBox6.Text
vocStart = TextBox5.Text
vocEnd = TextBox3.Text
svocStart = TextBox4.Text
svocEnd = TextBox2.Text
Dim
lastRow
As
Integer
lastRow = ws.Cells(ws.Rows.Count, 11).
End
(xlUp).Row + 2
Dim
formulaText
As
String
If
Not
CheckBox3.Value
Then
If
IsNumeric(vvocStart)
And
IsNumeric(vvocEnd)
Then
ws.Cells(lastRow, 11).Value =
"VVOC < 5 µg/m³"
formulaText =
"=SUMMEWENNS(M"
& vvocStart &
":M"
& vvocEnd &
", K"
& vvocStart &
":K"
& vvocEnd &
", "
"VVOC*"
")"
ws.Cells(lastRow, 13).Formula2 = formulaText
lastRow = lastRow + 1
End
If
End
If
If
Not
CheckBox5.Value
Then
If
IsNumeric(vocStart)
And
IsNumeric(vocEnd)
Then
ws.Cells(lastRow, 11).Value =
"VOC"
formulaText =
"=SUMME(M"
& vocStart &
":M"
& vocEnd &
")"
ws.Cells(lastRow, 13).Formula2Local = formulaText
lastRow = lastRow + 1
ws.Cells(lastRow, 11).Value =
"VOC < 5 µg/m³"
formulaText =
"=SUMMEWENN(K"
& vocStart &
":K"
& vocEnd &
","
">0"
",M"
& vocStart &
":M"
& vocEnd &
")"
ws.Cells(lastRow, 13).Formula2 = formulaText
lastRow = lastRow + 1
End
If
End
If
If
Not
CheckBox4.Value
Then
If
IsNumeric(svocStart)
And
IsNumeric(svocEnd)
Then
ws.Cells(lastRow, 11).Value =
"SVOC < 5 µg/m³"
formulaText =
"=SUMMEWENNS(M"
& svocStart &
":M"
& svocEnd &
", K"
& svocStart &
":K"
& svocEnd &
", "
"SVOC*"
")"
ws.Cells(lastRow, 13).Formula2 = formulaText
lastRow = lastRow + 1
End
If
End
If
Unload
Me
End
Sub