Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Problème avec Application match et Range(cells...

3 réponses
Avatar
JP
Bonjour,

J'ai un blocage sur cette ligne
X =3D Application.Match(c, .Range(Cells(11, 3), Cells(11, nbCompBac + 2)), =
0)=20

Alors que quand elle est =E9crite comme ceci:
X =3D Application.Match(c, .Range("C11:W11"), 0)

(Dans le premier cas 23 colonnes et dans le deuxi=E8me 23 colonnes aussi)


Pas de probl=E8me!
Quelqu'un aurait une id=E9e?

Merci

JP

Dim X As Variant, c As Range
With Worksheets("feuil1")

For Each c In .Range("B4:B" & nbCompBac + 2)
With Worksheets("feuil2")
X =3D Application.Match(c, .Range(Cells(11, 3), Cells(11, nbCom=
pBac + 2)), 0)=20
If Not IsError(X) Then
With .Range(Cells(11, 3), Cells(11, nbCompBac + 2))(1, X)
.ClearComments
.AddComment CStr(c.Offset(, 1).Value)
End With
Else
Err.Clear
End If
End With
Next
End With

3 réponses

Avatar
DanielCo
Bonjour,

L'erreur se produit si "Feuil2" n'est pas la feuille active. Il faut
mettre des "." devant "Cells" :

X = Application.Match(c, .Range(.X = Application.Match(c,
.Range(Cells(11, 3), Cells(11, nbCompBac + 2)), 0), .Cells(11,
nbCompBac + 2)), 0)
sinon, "range" se réfère à "Feuil2" et c"X = Application.Match(c,
.Range(Cells(11, 3), Cells(11, nbCompBac + 2)), 0)" et "Cells(11,
nbCompBac + 2)" se réfèrent à la feuille active.
Cordialement.
Daniel


Bonjour,

J'ai un blocage sur cette ligne
X = Application.Match(c, .Range(Cells(11, 3), Cells(11, nbCompBac + 2)), 0)

Alors que quand elle est écrite comme ceci:
X = Application.Match(c, .Range("C11:W11"), 0)

(Dans le premier cas 23 colonnes et dans le deuxième 23 colonnes aussi)


Pas de problème!
Quelqu'un aurait une idée?

Merci

JP

Dim X As Variant, c As Range
With Worksheets("feuil1")

For Each c In .Range("B4:B" & nbCompBac + 2)
With Worksheets("feuil2")
X = Application.Match(c, .Range(Cells(11, 3), Cells(11, nbCompBac
+ 2)), 0) If Not IsError(X) Then
With .Range(Cells(11, 3), Cells(11, nbCompBac + 2))(1, X)
.ClearComments
.AddComment CStr(c.Offset(, 1).Value)
End With
Else
Err.Clear
End If
End With
Next
End With
Avatar
DanielCo
Erratum; lire :

X = Application.Match(c, .Range(.Cells(11, 3), .Cells(11, nbCompBac +
2)), 0)

Daniel



Bonjour,

L'erreur se produit si "Feuil2" n'est pas la feuille active. Il faut mettre
des "." devant "Cells" :

X = Application.Match(c, .Range(.X = Application.Match(c, .Range(Cells(11,
3), Cells(11, nbCompBac + 2)), 0), .Cells(11, nbCompBac + 2)), 0)
sinon, "range" se réfère à "Feuil2" et c"X = Application.Match(c,
.Range(Cells(11, 3), Cells(11, nbCompBac + 2)), 0)" et "Cells(11, nbCompBac +
2)" se réfèrent à la feuille active.
Cordialement.
Daniel


Bonjour,

J'ai un blocage sur cette ligne
X = Application.Match(c, .Range(Cells(11, 3), Cells(11, nbCompBac + 2)), 0)

Alors que quand elle est écrite comme ceci:
X = Application.Match(c, .Range("C11:W11"), 0)

(Dans le premier cas 23 colonnes et dans le deuxième 23 colonnes aussi)


Pas de problème!
Quelqu'un aurait une idée?

Merci

JP

Dim X As Variant, c As Range
With Worksheets("feuil1")

For Each c In .Range("B4:B" & nbCompBac + 2)
With Worksheets("feuil2")
X = Application.Match(c, .Range(Cells(11, 3), Cells(11,
nbCompBac + 2)), 0) If Not IsError(X) Then
With .Range(Cells(11, 3), Cells(11, nbCompBac + 2))(1, X)
.ClearComments
.AddComment CStr(c.Offset(, 1).Value)
End With
Else
Err.Clear
End If
End With
Next
End With
Avatar
JP
Bonjour Daniel,

Effectivement, je pensais que le . devant range suffisait. Ben non!

Merci

JP