Je cherche à localiser dans une feuille des cellules qui sont repérées par
une "balise", en fait un commentaire.
Si le commentaire de la cellule correspond au critère de recherche, alors
j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de
recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en
sortie.
Function Balise(s As String) As Range
ligne = 0
colonne = 0
For Each Balise In Cells.SpecialCells(xlCellTypeComments)
With Balise.Comment
If .Text = s Then GoTo fin
End With
Next
fin:
End Function
Sub main()
Dim X As Range
X = Balise("col1")
L = X.Row
c = X.Column
End Sub
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
Daniel.C
Bonjour. Essaie avec : Set X = Balise("col1") Daniel "seb" a écrit dans le message de news: 4778a875$0$17285$
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Quelqu'un aurait-il une idée ?
Merci de votre aide.
Seb
Bonjour.
Essaie avec :
Set X = Balise("col1")
Daniel
"seb" <seb@hotmail.com> a écrit dans le message de news:
4778a875$0$17285$426a74cc@news.free.fr...
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par
une "balise", en fait un commentaire.
Si le commentaire de la cellule correspond au critère de recherche, alors
j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de
recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en
sortie.
Function Balise(s As String) As Range
ligne = 0
colonne = 0
For Each Balise In Cells.SpecialCells(xlCellTypeComments)
With Balise.Comment
If .Text = s Then GoTo fin
End With
Next
fin:
End Function
Sub main()
Dim X As Range
X = Balise("col1")
L = X.Row
c = X.Column
End Sub
Bonjour. Essaie avec : Set X = Balise("col1") Daniel "seb" a écrit dans le message de news: 4778a875$0$17285$
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Quelqu'un aurait-il une idée ?
Merci de votre aide.
Seb
LSteph
Bonjour,
... peut être lui dire qqpart set balise= lerangeenquestion ..non!?
;-)
@+
-- lSteph
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Quelqu'un aurait-il une idée ?
Merci de votre aide.
Seb
Bonjour,
... peut être lui dire qqpart
set balise= lerangeenquestion
..non!?
;-)
@+
--
lSteph
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par
une "balise", en fait un commentaire.
Si le commentaire de la cellule correspond au critère de recherche, alors
j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de
recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en
sortie.
Function Balise(s As String) As Range
ligne = 0
colonne = 0
For Each Balise In Cells.SpecialCells(xlCellTypeComments)
With Balise.Comment
If .Text = s Then GoTo fin
End With
Next
fin:
End Function
Sub main()
Dim X As Range
X = Balise("col1")
L = X.Row
c = X.Column
End Sub
... peut être lui dire qqpart set balise= lerangeenquestion ..non!?
;-)
@+
-- lSteph
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Option Explicit Private Const Sécu As Long = 10000 Dim Z As String, S As String ' ' Sub RecherchComTxt() Dim X As Range, W As Variant, F As Worksheet, R As Range Z = "A1:D1000": S = "ici" 'éventuels paramètres de RecherchComTxt (...) Set F = ActiveSheet: Set R = F.Range(Z) W = LaBalise(S, R) If IsArray(W) Then Set X = F.Range(W(0)) MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2)) Else MsgBox ("Introuvable " & W) End If End Sub ' Private Function LaBalise(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String For Each X In R.Cells i = i + 1: If i > Sécu Then LaBalise = "Dépassement": Exit Function T2 = TrouvCom(X) If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise = W Exit Function End If Next X End Function ' Private Function TrouvCom(ByRef R As Range) As String On Error GoTo Erreur_TrouvCom TrouvCom = R.Comment.Text Exit Function Erreur_TrouvCom: TrouvCom = "" End Function
Cordialement M41
"seb" a écrit dans le message de news: 4778a875$0$17285$
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Quelqu'un aurait-il une idée ?
Merci de votre aide.
Seb
Bonjour
Option Explicit
Private Const Sécu As Long = 10000
Dim Z As String, S As String
'
'
Sub RecherchComTxt()
Dim X As Range, W As Variant, F As Worksheet, R As Range
Z = "A1:D1000": S = "ici" 'éventuels paramètres de RecherchComTxt (...)
Set F = ActiveSheet: Set R = F.Range(Z)
W = LaBalise(S, R)
If IsArray(W) Then
Set X = F.Range(W(0))
MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2))
Else
MsgBox ("Introuvable " & W)
End If
End Sub
'
Private Function LaBalise(ByVal T As String, ByRef R As Range) As Variant
Dim i As Long, X As Range, W(3) As Variant, T2 As String
For Each X In R.Cells
i = i + 1: If i > Sécu Then LaBalise = "Dépassement": Exit Function
T2 = TrouvCom(X)
If T2 = S And T2 > "" Then
W(0) = X.Address
W(1) = X.Row
W(2) = X.Column
LaBalise = W
Exit Function
End If
Next X
End Function
'
Private Function TrouvCom(ByRef R As Range) As String
On Error GoTo Erreur_TrouvCom
TrouvCom = R.Comment.Text
Exit Function
Erreur_TrouvCom:
TrouvCom = ""
End Function
Cordialement
M41
"seb" <seb@hotmail.com> a écrit dans le message de news:
4778a875$0$17285$426a74cc@news.free.fr...
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par
une "balise", en fait un commentaire.
Si le commentaire de la cellule correspond au critère de recherche, alors
j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de
recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en
sortie.
Function Balise(s As String) As Range
ligne = 0
colonne = 0
For Each Balise In Cells.SpecialCells(xlCellTypeComments)
With Balise.Comment
If .Text = s Then GoTo fin
End With
Next
fin:
End Function
Sub main()
Dim X As Range
X = Balise("col1")
L = X.Row
c = X.Column
End Sub
Option Explicit Private Const Sécu As Long = 10000 Dim Z As String, S As String ' ' Sub RecherchComTxt() Dim X As Range, W As Variant, F As Worksheet, R As Range Z = "A1:D1000": S = "ici" 'éventuels paramètres de RecherchComTxt (...) Set F = ActiveSheet: Set R = F.Range(Z) W = LaBalise(S, R) If IsArray(W) Then Set X = F.Range(W(0)) MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2)) Else MsgBox ("Introuvable " & W) End If End Sub ' Private Function LaBalise(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String For Each X In R.Cells i = i + 1: If i > Sécu Then LaBalise = "Dépassement": Exit Function T2 = TrouvCom(X) If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise = W Exit Function End If Next X End Function ' Private Function TrouvCom(ByRef R As Range) As String On Error GoTo Erreur_TrouvCom TrouvCom = R.Comment.Text Exit Function Erreur_TrouvCom: TrouvCom = "" End Function
Cordialement M41
"seb" a écrit dans le message de news: 4778a875$0$17285$
Bonjour,
Je cherche à localiser dans une feuille des cellules qui sont repérées par une "balise", en fait un commentaire. Si le commentaire de la cellule correspond au critère de recherche, alors j'ai trouvé la cellule, si non, passe à la cellule suivante.
La function suivante permet de trouver la cellule suivant le critère de recherche souhaitée, mais je n'arrive pas à récupérer l'objet cellule en sortie.
Function Balise(s As String) As Range ligne = 0 colonne = 0 For Each Balise In Cells.SpecialCells(xlCellTypeComments) With Balise.Comment If .Text = s Then GoTo fin End With Next fin: End Function
Sub main() Dim X As Range X = Balise("col1") L = X.Row c = X.Column End Sub
Quelqu'un aurait-il une idée ?
Merci de votre aide.
Seb
M41
Ou plus simplement...
Option Explicit Private Const Sécu As Long = 10000 Dim Z As String, S As String ' ' Sub RecherchComTxt() Dim X As Range, W As Variant, F As Worksheet, R As Range Z = "A1:D1000": S = "ici" Set F = ActiveSheet: Set R = F.Range(Z) W = LaBalise2(S, R) If IsArray(W) Then Set X = F.Range(W(0)) MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2)) Else MsgBox ("Introuvable " & W) End If End Sub ' Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String Set R = R.Cells.SpecialCells(xlCellTypeComments) For Each X In R i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function T2 = R.Comment.Text If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise2 = W Exit Function End If Next X End Function
Cordialement M41
Ou plus simplement...
Option Explicit
Private Const Sécu As Long = 10000
Dim Z As String, S As String
'
'
Sub RecherchComTxt()
Dim X As Range, W As Variant, F As Worksheet, R As Range
Z = "A1:D1000": S = "ici"
Set F = ActiveSheet: Set R = F.Range(Z)
W = LaBalise2(S, R)
If IsArray(W) Then
Set X = F.Range(W(0))
MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2))
Else
MsgBox ("Introuvable " & W)
End If
End Sub
'
Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant
Dim i As Long, X As Range, W(3) As Variant, T2 As String
Set R = R.Cells.SpecialCells(xlCellTypeComments)
For Each X In R
i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function
T2 = R.Comment.Text
If T2 = S And T2 > "" Then
W(0) = X.Address
W(1) = X.Row
W(2) = X.Column
LaBalise2 = W
Exit Function
End If
Next X
End Function
Option Explicit Private Const Sécu As Long = 10000 Dim Z As String, S As String ' ' Sub RecherchComTxt() Dim X As Range, W As Variant, F As Worksheet, R As Range Z = "A1:D1000": S = "ici" Set F = ActiveSheet: Set R = F.Range(Z) W = LaBalise2(S, R) If IsArray(W) Then Set X = F.Range(W(0)) MsgBox (W(0) & " = L-C : " & W(1) & " - " & W(2)) Else MsgBox ("Introuvable " & W) End If End Sub ' Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String Set R = R.Cells.SpecialCells(xlCellTypeComments) For Each X In R i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function T2 = R.Comment.Text If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise2 = W Exit Function End If Next X End Function
Cordialement M41
M41
Glop !
Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String On Error GoTo Erreur_LaBalise2 Set R = R.Cells.SpecialCells(xlCellTypeComments) For Each X In R i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function T2 = R.Comment.Text If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise2 = W Exit Function End If Next X Exit Function Erreur_LaBalise2: LaBalise2 = "No comment !" End Function
M41
Glop !
Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant
Dim i As Long, X As Range, W(3) As Variant, T2 As String
On Error GoTo Erreur_LaBalise2
Set R = R.Cells.SpecialCells(xlCellTypeComments)
For Each X In R
i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function
T2 = R.Comment.Text
If T2 = S And T2 > "" Then
W(0) = X.Address
W(1) = X.Row
W(2) = X.Column
LaBalise2 = W
Exit Function
End If
Next X
Exit Function
Erreur_LaBalise2:
LaBalise2 = "No comment !"
End Function
Private Function LaBalise2(ByVal T As String, ByRef R As Range) As Variant Dim i As Long, X As Range, W(3) As Variant, T2 As String On Error GoTo Erreur_LaBalise2 Set R = R.Cells.SpecialCells(xlCellTypeComments) For Each X In R i = i + 1: If i > Sécu Then LaBalise2 = "Dépassement": Exit Function T2 = R.Comment.Text If T2 = S And T2 > "" Then W(0) = X.Address W(1) = X.Row W(2) = X.Column LaBalise2 = W Exit Function End If Next X Exit Function Erreur_LaBalise2: LaBalise2 = "No comment !" End Function
M41
seb
Bonjour M41,
Bel exemple qui permet d'élargir le champ d'application,
Juste remplacer T2=R.Comment.Text par T2=X.Comment.Text
Merci.
seb
Bonjour M41,
Bel exemple qui permet d'élargir le champ d'application,
Juste remplacer T2=R.Comment.Text par T2=X.Comment.Text