Salut h2so4, m3ellem1 !
Les macro travaillent sur toutes les feuilles, car le resultat ne change pas quelques soit l'onglet selectionner
En l'absence de précision sur la feuille dans le code, il s'agit de la feuille active. Une adaptation pour préciser la feuille :
Sub testhttp()
Dim Cel As Range, I As Integer, Nb As Long, NbLig As Long
NbLig = 19000
For Each Cel In Sheets("MaFeuille").Range("A1:A" & Nblig) '
For I = 1 To Len(Cel.Value) - 4
If Mid(Cel.Value,I,4) = "http" then Nb=Nb+1
Next I
Next Cel
MsgBox "Nombre d’occurrences : " & Nb
End Sub
Autre proposition avec une fonction personnalisée, utilisable comme une fonction Excel classique :
Function CompterOccurence(Plage As Range, Texte As String) As Long
Dim Cel As Range, I As Integer, Nb As Long
For Each Cel In Plage
For I = 1 To Application.Max(Len(Cel.Value) - Len(Texte), 1)
If Mid(Cel.Value,I,Len(Texte)) = Texte then Nb=Nb+1
Next I
Next Cel
CompterOccurence = Nb
End Function
Dans une cellule du classeur :
=CompterOccurence(A1:A19000;"http")