Private Sub ComboBox1_Change()
With ComboBox1
If CStr(ComboBox1.Text) = "" Then
For Each c In Split("F8,X8,F9,V9,X9,V12,V13,V15,B17,F17,N17,X17", ",")
Sheets("Factures Client").Range(c).Value = ""
Next
End If
If .ListIndex = -1 Then Exit Sub
For Each c In Split("F8,X8,F9,V9,X9,V12,V13,V15,B17,F17,N17,X17", ",")
Sheets("Factures Client").Range(c).Value = Sheets(.Text).Range(c).Value
Next
End With
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If ComboBox1.ListIndex = -1 And CStr(ComboBox1.Text) <> "" Then
If MsgBox(ComboBox1.Text & " n'xiste pas voulez voue le rajouter", vbQuestion + vbYesNo) = vbYes Then
If IsSheetExist(ComboBox1.Text) Then MsgBox ComboBox1.Text & " Existe déjà", vbExclamation: Exit Sub
Application.DisplayAlerts = False
Sheets("Model Facture").Copy After:=Sheets(Sheets.Count)
ComboBox1.AddItem ComboBox1.Text
Sheets(Sheets.Count).Name = ComboBox1.Text
Sheets("Factures Client").Select
Application.DisplayAlerts = True
End If
End If
End If
End Sub
Function IsSheetExist(ByVal sh As String) As Boolean
On Error Resume Next
sh = Sheets(sh).Name
IsSheetExist = Not CBool(Err)
On Error GoTo 0
End Function
Private Sub CommandButton1_Click()
With ComboBox1
If .ListIndex = -1 Then Exit Sub
For Each c In Split("F8,X8,F9,V9,X9,V12,V13,V15,B17,F17,N17,X17", ",")
Sheets(.Text).Range(c).Value = Sheets("Factures Client").Range(c).Value
Next
End With
End Sub
Private Sub Worksheet_Activate()
Dim i As Integer, sh As String
If ComboBox1.ListIndex > -1 Then sh = ComboBox1.Text
ComboBox1.Clear
For i = ActiveSheet.Index + 1 To Sheets.Count
ComboBox1.AddItem Sheets(i).Name
Next
If CStr(sh) <> "" Then ComboBox1.Text = sh
End Sub