Private Sub CommandButton_SaveData_Click()
Dim Plage As Range, i, ii, Ligne, Ligne2 As Long, Nom As String
Dim Ctrl As Control
Application.DisplayAlerts = False
If MsgBox("Are you sure you want to save your changes?", vbYesNo, "Confirmation request") = vbYes Then
With Sheets("Param")
Set Plage = .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
End With
'****************** Write Data in spéficique file *************************************************************
With Sheets("TIA")
.Activate
Ligne = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
If IsNumeric(Application.Match(CLng(Me.TextBox_EquipementSAP.Text), .[G:G], 0)) Then ' find equipment N° in colum A, we have a numerical result
Ligne = Application.Match(CLng(Me.TextBox_EquipementSAP.Text), .[G:G], 0) ' get the line number
Else
Ligne = .Cells(.Rows.Count, 1).End(xlUp).Row + 1 ' empty line
End If
For i = 1 To 94 ' 98 critères à enregistés'
Nom = Plage(i).Offset(, 1)
If Nom <> "" Then .Cells(Ligne, i) = Me.Controls(Nom).Value ' on sauvegarde toute la ligne'
Next i
End With
End If
End Sub