XL 2016 Recherche valeur dans une boucle

anis.abbadi

XLDnaute Nouveau
Bonjour à tous,

Voici le code que j'ai :

Code:
Sub enreg_intervenant()

Dim src As Worksheet
Set src = ActiveSheet

Dim nomfeuille As String
nomfeuille = ActiveSheet.name


Application.ScreenUpdating = False
Dim j As Integer
With Sheets("Analyse")
If .Cells(8, 5) = "" And .Cells(9, 5) = "" Then j = 8
If .Cells(8, 5) <> "" And .Cells(9, 5) = "" And .Cells(10, 5) = "" Then j = 9
If .Cells(9, 5) <> "" And .Cells(10, 5) = "" And .Cells(11, 5) = "" Then j = 10
If .Cells(10, 5) <> "" And .Cells(11, 5) = "" And .Cells(12, 5) = "" Then j = 11
If .Cells(11, 5) <> "" And .Cells(12, 5) = "" And .Cells(13, 5) = "" Then j = 12
If .Cells(12, 5) <> "" And .Cells(13, 5) = "" And .Cells(14, 5) = "" Then j = 13
If .Cells(13, 5) <> "" And .Cells(14, 5) = "" And .Cells(15, 5) = "" Then j = 14
If .Cells(14, 5) <> "" And .Cells(15, 5) = "" And .Cells(16, 5) = "" Then j = 15
If .Cells(15, 5) <> "" And .Cells(16, 5) = "" And .Cells(17, 5) = "" Then j = 16
If .Cells(16, 5) <> "" And .Cells(17, 5) = "" And .Cells(18, 5) = "" Then j = 17
If .Cells(17, 5) <> "" And .Cells(18, 5) = "" And .Cells(19, 5) = "" Then j = 18
If .Cells(18, 5) <> "" And .Cells(18, 5) <> "" And .Cells(19, 5) = "" Then j = 19
End With
  
'Dim c As Range
'For Each c In Worksheets("Analyse").Range("C8:C19")
'If c.Value = nomfeuille Then j = ActiveCell.Row
'Next c
  
With src
.Activate
.Range("E24:V24").Copy
Sheets("Analyse").Range("E" & j).PasteSpecial Paste:=xlPasteValues
End With
Sheets("Analyse").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Chaque feuille à le nom d'une ligne dans le tableau "Analyse".
Ce code me permet de récupérer une ligne de valeur depuis la feuille active et de la recopier dans la feuille "Analyse" à la suite. Cependant j'ai mis en commentaires une boucle où je recherche si une ligne à déjà été enregistrée pour faire une mise à jour des données et non de noté à la suite. L'indice "j" est important mais je n'arrive pas à récupérer la bonne valeur de ligne.

Merci de votre aide
 

Statistiques des forums

Discussions
312 090
Messages
2 085 210
Membres
102 820
dernier inscrit
SIEG68