1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| ...
ElseIf Feuille.Text = "New Entry" Then
Worksheets.Add.Name = nouveau
nom = Worksheets(nouveau).CodeName
With ThisWorkbook.VBProject.VBComponents(nom).CodeModule
X = .CountOfLines
.InsertLines X + 1, "Private Sub Worksheet_Change(ByVal Target As Range)"
.InsertLines X + 3, "Dim n as Integer"
.InsertLines X + 5, "For n = 1 To Worksheets.Count"
.InsertLines X + 6, " If Worksheets(n).Name = activesheet.Name Then"
.InsertLines X + 7, " Exit For"
.InsertLines X + 8, " End If"
.InsertLines X + 9, "Next"
.InsertLines X + 11, "If Target.Row <= FirstLine - 1 Then"
.InsertLines X + 12, " If Range(""Fin"" & n).Row > FirstLine - 1 Then"
.InsertLines X + 13, " activesheet.Rows(Selection.Row).Delete"
.InsertLines X + 14, " MsgBox ""You are not allowed to insert rows on this part of the sheet"", vbExclamation, ""Not Allowed"""
.InsertLines X + 15, " End If"
.InsertLines X + 16, "ActiveWorkbook.Names.Add Name:=""Fin"" & n, RefersTo:=ActiveSheet.Range(""A"" & FirstLine - 1)"
.InsertLines X + 17, "End If"
.InsertLines X + 19, "End Sub"
End With
End If |
Partager