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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| Public m As String 'nom des feuilles
Private Sub ccomm_Change()
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 12).Value = ccomm.Value
End Sub
Private Sub CommandButton1_Click()
ThisWorkbook.Save
End Sub
Private Sub datejour_Change()
Dim x As Integer
'traitement des dates (anglaise en français)
x = InStr(1, datejour.Value, "/")
If x <> 0 Then
x = InStr(x + 2, datejour.Value, "/")
If x <> 0 And Len(datejour.Value) > x Then
'reconstitution date française
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 10) = Month(datejour.Value) & "/" & Day(datejour.Value) & "/" & Year(datejour.Value)
Else
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 10) = datejour.Value 'en attendant la suite
End If
End If
End Sub
Private Sub nnomm_Change()
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 11).Value = nnomm.Value
End Sub
Private Sub Tpese_Change()
Dim st As String
Dim bool As Boolean
Application.EnableEvents = False
'traitement des nombres
If Tpese.Text <> "" Then
'si on utilise en saisie le point pour la virgule
If InStr(1, Tpese.Text, ".") <> 0 Then Tpese.Text = Replace(Tpese.Text, ".", ",")
'reconstituer le nombre version anglaise
If InStr(1, Tpese.Text, ",") <> 0 Then
st = Tpese.Text
st = Replace(st, ",", ".")
Else
st = Tpese.Text
End If
If IsNumeric(Tpese.Value) Then
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 7) = st
Else
'si on ne tape pas chiffre ou virgule
ActiveSheet.Cells(ComboBox2.ListIndex + 6, 7) = ""
Tpese.Text = ""
bool = MsgBox("Vous devez saisir un nombre", vbOKOnly, "Attention !")
End If
End If
Application.EnableEvents = True
End Sub
Private Sub UserForm_Initialize()
Application.EnableEvents = False
For Each S In ActiveWorkbook.Sheets
Me.ComboBox1.AddItem S.Name
Next S
Me.ComboBox1.ListIndex = 0
m = ComboBox1.List(0)
Sheets(m).Activate
nnomm.RowSource = Sheets(m).Range("N6:N13").Address
Application.EnableEvents = True
End Sub
Private Sub ComboBox2_Change()
Application.EnableEvents = False
Cells(ComboBox2.ListIndex + 6, 1).Activate
tniveau.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 2).Text
tmodels.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 3).Text
tcapacite.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 9).Text
ttare.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 4).Text
tpoids.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 5).Text
ttromblon.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 6).Text
ddiff.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 8).Text
datejour.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 10).Text
nnomm.Value = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 11).Value
Tpese.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 7).Text
ccomm.Text = ActiveSheet.Cells(ComboBox2.ListIndex + 6, 12).Text
Application.EnableEvents = True
End Sub
Private Sub CommandButton2_Click()
MsgBox ("Merci de votre visite!"), vbInformation, "A BIENTOT!"
Unload Menu 'Application.Quit (à remettre si on veut sortir du fichier)
End Sub
Private Sub ComboBox1_Change()
Dim source As Range, c As Range
m = Me.ComboBox1.Value
Sheets(m).Select
'entrer la liste des noms en colonne N ligne 6 (peut être à cacher!)
nnomm.RowSource = Sheets(m).Range(Cells(6, 14), Cells(6, 14).End(xlDown)).Address
nnomm.Value = ""
'entrer la liste des Numéros dans le combo2
Set source = ActiveSheet.Range(Cells(6, 1), Cells(6, 1).End(xlDown))
ComboBox2.RowSource = source.Address
ComboBox2.ListIndex = 0
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub |