Ich möchte in Spalte B die Zellen suchen welche den Begriff "Hallo" enthalten. Den erhaltenen Wert soll es mir in einer msgBox als Zahl (zum Beispiel 6) ausgeben. Kann mir da jemand behilflich sein?
Gruss Daniel
Sub Unit()
Const strText As String = "Hallo"
MsgBox WorksheetFunction.CountIf(Columns("B"), strText)
End Sub
Option Explicit
Sub SpalteB()
Dim Loletzte As Long
Dim LoI As Long
Loletzte = IIf(IsEmpty(Cells(Rows.Count, 2)), Cells(Rows.Count, 1).End(xlUp).Row, Rows. _
Count)
For LoI = 1 To Loletzte
If Cells(LoI, 2) = "Hallo" Then
MsgBox LoI
End If
Next LoI
End Sub
Sub Unit()
Dim C As Range
For Each C In Columns(2).SpecialCells(2, 2)
If C.Value = "Hallo" Then MsgBox C.Address(0, 0, 1)
Next
End Sub