1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Sub addVBA(workbookName As String)
Dim y As Integer
'plante à la ligne suivante
With ActiveWorkbook.VBProject.VBComponents(Worksheets(1).CodeName).CodeModule
y = .CountOfLines
.InsertLines y + 1, "Private Sub Worksheet_Change(ByVal Target As Range)"
.InsertLines y + 2, "If Target.Count > 1 Then"
.InsertLines y + 3, "Exit Sub"
.InsertLines y + 4, "End If"
.InsertLines y + 5, "Dim Plage As Range"
.InsertLines y + 6, "Set Plage = Range(""K:K"")"
.InsertLines y + 7, "If Not Application.Intersect(Target, Plage) Is Nothing Then"
.InsertLines y + 8, "If StrComp(Target, ""fait le"", vbTextCompare) = 0 Or StrComp(Target, ""RDV le"", vbTextCompare) = 0 Or StrComp(Target, ""pas prêt le"", vbTextCompare) = 0 Then"
.InsertLines y + 9, "CalendarUF.Show"
.InsertLines y + 10, "End if"
.InsertLines y + 11, "End if"
.InsertLines y + 12, "End sub"
End With
ActiveWorkbook.VBProject.VBComponents.Import "C:\Temp\macroRelance\calendar.frm"
End Sub |
Partager