Correction Macro

Bonjour,

J'ai un morceau de macro ou je voudrais modifié quelque chose mais je ne sais pas comment procéder la feuil2 est un fichier excel à part il faudrait donc remplacer feuil2 par fichier excel Gestion feuil 6 ? Help me please

Feuil1.Cells.ClearComments
With Feuil2
For Lg02 = 10 To .Range("B65536").End(xlUp).Row
If .Cells(Lg02, 2) <> "" Then
Num = .Cells(Lg02, 2)
Lg01 = 0
With Feuil1
Set Cel = .Range("B10:B" & .Range("B65536").End(xlUp).Row).Find(what:=Num, LookIn:=xlValues, lookat:=xlWhole)
If Not Cel Is Nothing Then
Lg01 = Cel.Row
End If
End With

2 réponses

  • Votes
  • Date
  • Date décroissante
  1. Pas facile à comprendre !
    Le code est très incomplet ! (entre autres, il manque un End With)

    Remplace Feuil2 par Workbook("Gestion").Feuil6

    (Le fichier Gestion doit être ouvert)

    PS : Avec Excel 2007 il faut éviter .Range("B65536").End(xlUp)
    1. Voici la macro au complet mais elle ne fonctionne toujours pas j'ai mis woekbook ("Gestion").Feuil6 mais ca me met erreur? :-(

      Option Explicit

      Sub Commentaires()
      Dim Lg01 As Long
      Dim Lg02 As Long
      Dim Lg As Long
      Dim Cl01 As Long
      Dim Cel As Range
      Dim Mot As String
      Dim Nom As String
      Dim Num As Integer

      Dim I As Long
      Mot = "HORJOURSRIX"
      Feuil1.Cells.ClearComments
      With Workbook("Gestion").Feuil6
      For Lg02 = 10 To .Range("B65536").End(xlUp).Row
      If .Cells(Lg02, 2) <> "" Then
      Num = .Cells(Lg02, 2)
      Lg01 = 0
      With Feuil1
      Set Cel = .Range("B10:B" & .Range("B65536").End(xlUp).Row).Find(what:=Num, LookIn:=xlValues, lookat:=xlWhole)
      If Not Cel Is Nothing Then
      Lg01 = Cel.Row
      End If
      End With
      If Lg01 <> 0 Then
      Lg = Lg02
      While .Cells(Lg, 15) <> ""
      Cl01 = 1 + (.Cells(Lg, 15) * 4) + Int(InStr(1, Mot, .Cells(Lg, 13)) / 3)
      Nom = .Cells(Lg, 16) & "/" & .Cells(Lg, 17) & "/" & .Cells(Lg, 18)
      While Right(Nom, 1) = "/"
      Nom = Left(Nom, Len(Nom) - 1)
      Wend
      With Feuil1.Cells(Lg01, Cl01)
      If .Comment Is Nothing Then
      .AddComment
      .Comment.Text Text:="Info:" & vbLf
      End If
      .Comment.Text Text:=.Comment.Text & Nom & vbLf
      .Comment.Shape.TextFrame.AutoSize = True
      End With
      Lg = Lg + 1
      Wend
      End If
      End If
      Next Lg02
      End With

      End Sub