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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   | 'enregistrement et protection blocage des donnees'
 
Private Sub Btn_maj_feuille_Click()
 
Dim l_info As Integer
Dim note_1 As String, note_2 As String, lanote As String
 
 
With ThisWorkbook.Worksheets("TABLEAU RECAP")
        l_info = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
        .Range("B" & l_info).Value = ComEQUI 'libelle equipement'
        .Range("c" & l_info).Value = Textlocal 'code local"
        .Range("D" & l_info).Value = ComRESP 'Nom du responsable'
        .Range("E" & l_info).Value = TextDATEAM 'date du constat'
        .Range("F" & l_info).Value = TextMISE 'date de mise en service'
        .Range("G" & l_info).Value = CInt(TextDUREVIE.Value)  'Duree de vie theorique'
        .Range("H" & l_info).Value = TextREMPL 'Date theorique de remplacement '
        .Range("I" & l_info).Value = CInt(TextDURVIERESI.Value)  'Duree de vie residuelle '
        .Range("J" & l_info).Value = TextESTIMREMPL 'Duree de vie residuelle '
        .Range("K" & l_info).Value = CInt(TextRESUETAT.Value) 'note de etat equipement'
        .Range("l" & l_info).Value = CInt(TextRESUCRIT.Value) 'note de criticite equipement'
 
         With .Range("M" & l_info)
                'formulation
                .FormulaR1C1 = "=IF(RC[-2]<=21,""Mauvais"",IF(RC[-2]<=43,""Usuel"",IF(RC[-2]<=64,""Bon"")))"
                'équivaut à un collage spécial valeur (merci au grand mercatog)
                .Value = .Value
                note_1 = .Value
         End With
 
         With .Range("N" & l_info)
                'formulation
                .FormulaR1C1 = "=IF(RC[-2]<=21,""Faible"",IF(RC[-2]<=43,""Moyenne"",IF(RC[-2]<=64,""Forte"")))"
                'équivaut à un collage spécial valeur (merci au grand mercatog)
                .Value = .Value
                note_2 = .Value
         End With
 
        Select Case True
                    Case note_1 = "Mauvais" And note_2 = "Faible"
                            lanote = "b"
                    Case note_1 = "Mauvais" And note_2 = "Moyenne"
                            lanote = "c"
                     'etc...
        End Select
 
        .Range("O" & l_info).Value = lanote
        .Range("P" & l_info).Value = TextCOMM 'texte dans commentaire
 
 End With
 
Me.hide
Unload Me
 
End Sub | 
Partager