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 27 28 29 30 31 32 33 34 35 36 37
| Option Explicit
' VBE menu "Tools" > "Reference"
' [x] Microsoft Visual Basic for Applications Extensibility
Sub UpdateModule()
Const nameModuleRemove = "Module11"
Const filenameModule = "Module11.bas" ' Correctif
Dim classeur As Workbook, indMod As Integer, vbCmpMod As VBIDE.VBComponent
Set classeur = ThisWorkbook
With classeur.VBProject.VBComponents
On Error Resume Next
Set vbCmpMod = .Item(nameModuleRemove)
On Error GoTo 0
If Not vbCmpMod Is Nothing Then
.Remove vbCmpMod
.Import ThisWorkbook.Path + "\" + filenameModule
'SheetPatch classeur ' Not tested
End If
End With
End Sub
Sub SheetPatch(classeur As Workbook)
Const nameAuthor = "alexandre"
Const indSheetPatch = 1
Const nameRangePatch = "chek"
Const formulaPatch = "=IF(entree_nominale^2+tol_sup_entree_a^2+tol_inf_entree_a^2=0,""Empty"",IF(RC[7]<>0,""NOk"",""OK""))"
With classeur.Sheets(indSheetPatch)
.Unprotect nameAuthor
.Range(nameRangePatch).FormulaR1C1 = formulaPatch
.Protect (nameAuthor), DrawingObjects:=False, Contents:=True, _
Scenarios:=False, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
End With
End Sub |
Partager