Bonjour à tous et à toutes,
Je voudrais modifier cette macro mais je n'ai jamais fait ce genre de modification et je ne sais pas comment faire. Actuellement cette macro utilise la feuil1 et la feuil2 et je voudrais qu'elle utilise toujours la feuil1 mais la feuil2 a été déplacée sur un autre classeur qui s'appelle "Données 2011" sur la feuil 6 et je ne sais pas comment faire. J'utilise récemment excel 2007 (si jamais) merci beaucoup.
Il semblerait qu'avec 2007 je dois éviter d'avoir une macro qui contient .Range("B65536").End(xlUp) pourquoi ? Que puis-je mettre à la place?
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
' Abs Hor Vac Rec
Mot = "AbsHorVacRec"
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
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 ' Création commentaire
.Comment.Text Text:="Info:" & vbLf ' Initialisation
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
Je voudrais modifier cette macro mais je n'ai jamais fait ce genre de modification et je ne sais pas comment faire. Actuellement cette macro utilise la feuil1 et la feuil2 et je voudrais qu'elle utilise toujours la feuil1 mais la feuil2 a été déplacée sur un autre classeur qui s'appelle "Données 2011" sur la feuil 6 et je ne sais pas comment faire. J'utilise récemment excel 2007 (si jamais) merci beaucoup.
Il semblerait qu'avec 2007 je dois éviter d'avoir une macro qui contient .Range("B65536").End(xlUp) pourquoi ? Que puis-je mettre à la place?
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
' Abs Hor Vac Rec
Mot = "AbsHorVacRec"
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
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 ' Création commentaire
.Comment.Text Text:="Info:" & vbLf ' Initialisation
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
Dernière édition: