Recherchev sur VBA

Bonjour à tous ,

Mon code ne fonctionne pas et il me met la ligne ci dessous en jaune :

col = ThisWorkbook.Sheets("matrice 1").Row(1).Find(DateToFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False).Column

Sub prévision()
Dim champ As Range
Dim DateToFind As String
Dim cel As Range
Dim col As Long
DateToFind = DateSerial(Year(Date), Month(Date), 1)
Set champ = Sheets("BDD1").Range("AL:AL").End(xlDown)
For Each cel In champ
col = ThisWorkbook.Sheets("matrice 1").Row(1).Find(DateToFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False).Column
Sheets("matrice 1").UsedRange.AutoFilter X, "FDR"
Dim lig As Long
lig = ThisWorkbook.Sheets("matrice 1").Range("R:R").SpecialCells(xlVisible).Find(cel.Value, LookAt:=xlWhole, MatchCase:=False).Row
cel.Offset(0, 17).Value = Sheets("matrice 1").Cells(lig, col).Value
Next cel
End Sub

Cordialement

Bonjour...j'ai toujours vu qu'il fallait asseter la variable range qui contient une méthode find...ALors peut-être essayez d'écrire

set col = ThisWorkbook.Sheets("matrice 1").Row(1).Find(DateToFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False).Column

Je viens d'essayer, erreur objet requis ?

Rows("1:1") 

?

Merci


Bonjour,

La macro marche super bien sauf elle est super lente . est ce qu'il y a un moyen de la simplifier.

Sub prévision()
On Error Resume Next
Dim champ As Range
Dim cel As Range
Dim col As Long
Dim last As Long
last = Sheets("BDD1").Range("AL3").End(xlDown).Row
Set champ = Sheets("BDD1").Range("AL3:AL" & last)
Sheets("matrice 1").UsedRange.AutoFilter 28, "FDR"
col = ThisWorkbook.Sheets("matrice 1").Range("B1:RZ1").Find(Sheets("BDD1").Range("AZ1"), LookAt:=xlWhole).Column
For Each cel In champ
Dim lig As Long
lig = ThisWorkbook.Sheets("matrice 1").Range("R:R").SpecialCells(xlVisible).Find(cel.Value, LookAt:=xlWhole).Row
cel.Offset(0, 16).Value = Sheets("matrice 1").Cells(lig, col).Value
Next cel
End Sub

Bien cordialement

Rechercher des sujets similaires à "recherchev vba"