Function mit boolean Eingabewert
11.10.2012 17:00:45
TobiasS
ich habe mir eine kleine Funktion geschrieben.
ich versuche sie in einer Prozedur wie folgt anzuwenden:
FE_comments(negative = TRUE) oder für den anderen fall
FE_comments(negative = FALSE).
D.h. wenn negative = TRUE ist, summiert er mir strings in spalte 6, wenn spalte 34 einen wert aufweist,
wenn negative = FALSE ist, summiert er mir strings in Spalte 5, wenn spalte 33 einen wert aufweist.
beim aufrufen der funktion sagt er mir aber immer, dass die variable "negative" nicht deklariert wurde.
könnte mir vielleicht jemand sagen, was ich falsch mache?
Danke schonmal!!
Tobi
Public Function FE_comments(negative As Boolean) As Long
Dim letztekom As Long
Const Spalte1 = 5
Const Spalte2 = 33
If negative = True Then
Spalte1 = Spalte1 + 1
Spalte2 = Spalte2 + 1
Dim wsblatt As Worksheet
Set wsblatt = Worksheets("Tabelle1")
With wsblatt
letztekom = .Cells(Rows.count, Spalte).End(xlUp).Row
FE_comments = 0
For i = 3 To letztekom
If .Cells(i, Spalte2) = 1 And .Cells(i, Spalte1) "" Then
FE_comments = FE_comments + 1
Else
FE_comments = FE_comments + 0
End If
Next
End With
End Function