voici les valeurs que j'ai dans une feuille excel.
a
b
c
a
b
a
je voudrais creer une fonction qui me retourne le nombre de "a" (ici 3)
voici mon code :
------------------------------------------------
Function test()
test = 0
With Worksheets(1).Range("a:a")
Set c = .Find("a", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
test = test + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Function
------------------------------------------------
Le probleme est que findnext retourne toujours Nothing...
j'utilise excel xp avec windows 2000
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
...Patrick
Salut,
tu as vraiment besoin de réinventer la roue ?
un nb.si peut fonctionner
Bye
"pierre" a écrit dans le message de news:
Bonjour,
voici les valeurs que j'ai dans une feuille excel. a b c a b a
je voudrais creer une fonction qui me retourne le nombre de "a" (ici 3) voici mon code :
------------------------------------------------ Function test() test = 0 With Worksheets(1).Range("a:a") Set c = .Find("a", LookIn:=xlValues) If Not c Is Nothing Then FirstAddress = c.Address Do test = test + 1 Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> FirstAddress End If End With End Function ------------------------------------------------
Le probleme est que findnext retourne toujours Nothing... j'utilise excel xp avec windows 2000
Merci pour votre aide.... pierre
Salut,
tu as vraiment besoin de réinventer la roue ?
un nb.si peut fonctionner
Bye
"pierre" <pierre@discussions.microsoft.com> a écrit dans le message de news:
6EF0D21E-C045-4A30-BD42-A4EF98AEE6DC@microsoft.com...
Bonjour,
voici les valeurs que j'ai dans une feuille excel.
a
b
c
a
b
a
je voudrais creer une fonction qui me retourne le nombre de "a" (ici 3)
voici mon code :
------------------------------------------------
Function test()
test = 0
With Worksheets(1).Range("a:a")
Set c = .Find("a", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
test = test + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Function
------------------------------------------------
Le probleme est que findnext retourne toujours Nothing...
j'utilise excel xp avec windows 2000
voici les valeurs que j'ai dans une feuille excel. a b c a b a
je voudrais creer une fonction qui me retourne le nombre de "a" (ici 3) voici mon code :
------------------------------------------------ Function test() test = 0 With Worksheets(1).Range("a:a") Set c = .Find("a", LookIn:=xlValues) If Not c Is Nothing Then FirstAddress = c.Address Do test = test + 1 Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> FirstAddress End If End With End Function ------------------------------------------------
Le probleme est que findnext retourne toujours Nothing... j'utilise excel xp avec windows 2000
Merci pour votre aide.... pierre
pierre
je voulais simplifier le code, il vrai que je l'ai peut etre trop simplifer... mais en realité, voici ce que je veux faire :
---------------------------------------------- Function BUDGET(sheetname As String, account As Variant) BUDGET = 0 With Worksheets(sheetname).Range("A:A") Set c = .Find(What:¬count) If Not c Is Nothing Then firstAddress = c.Address Do BUDGET = BUDGET + Worksheets(sheetname).Cells(c.row, 2).Value Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With End Function ----------------------------------------------
pierre
"...Patrick" wrote:
Salut,
tu as vraiment besoin de réinventer la roue ?
un nb.si peut fonctionner
Bye
"pierre" a écrit dans le message de news:
je voulais simplifier le code, il vrai que je l'ai peut etre trop simplifer...
mais en realité, voici ce que je veux faire :
----------------------------------------------
Function BUDGET(sheetname As String, account As Variant)
BUDGET = 0
With Worksheets(sheetname).Range("A:A")
Set c = .Find(What:¬count)
If Not c Is Nothing Then
firstAddress = c.Address
Do
BUDGET = BUDGET + Worksheets(sheetname).Cells(c.row,
2).Value
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Function
----------------------------------------------
pierre
"...Patrick" wrote:
Salut,
tu as vraiment besoin de réinventer la roue ?
un nb.si peut fonctionner
Bye
"pierre" <pierre@discussions.microsoft.com> a écrit dans le message de news:
6EF0D21E-C045-4A30-BD42-A4EF98AEE6DC@microsoft.com...
je voulais simplifier le code, il vrai que je l'ai peut etre trop simplifer... mais en realité, voici ce que je veux faire :
---------------------------------------------- Function BUDGET(sheetname As String, account As Variant) BUDGET = 0 With Worksheets(sheetname).Range("A:A") Set c = .Find(What:¬count) If Not c Is Nothing Then firstAddress = c.Address Do BUDGET = BUDGET + Worksheets(sheetname).Cells(c.row, 2).Value Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With End Function ----------------------------------------------