ich habe ein Excel VBA Problemchen :-(
Ich muss die Anzahl der Wörter in einer Filter-Auswahl zählen und dann in eine bestimmte Zelle in einem anderen Blatt eintragen. Erstmal wollte ich mir die Anzahl aber ausgeben lassen, um zu sehen, ob die Anzahl stimmt.
Ich schaffe es noch nicht das Zählen auf die ausgewählte Zellen zu beschränken.
Hier ist was ich bis jetzt habe:
Sub CountWords()
Dim cell As Range, rng As Range
ActiveSheet.Range("$A$14:$G$645").AutoFilter Field:=5, Criteria1:="1"
ActiveSheet.Range("$A$14:$G$645").AutoFilter Field:=6, Criteria1:="0"
Set rng = Range("$A$14:$G$645")
For Each cell In rng.SpecialCells(xlCellTypeVisible)
If Not cell.HasFormula Then
Content = cell.Value
Content = Trim(Content)
If Content = "" Then
cellWords = 0
Else
cellWords = 1
End If
Do While InStr(Content, " ") > 0
Content = Mid(Content, InStr(Content, " "))
Content = Trim(Content)
cellWords = cellWords + 1
TotalWords = TotalWords + cellWords
Loop
End If
Next cell
MsgBox TotalWords & " words found in the selected range."
End Sub
Ich hoffe, ihr könnt mir helfen.Im Voraus schon mal vielen Dank!
Julia