VBA Sortir de InputBox + réduction de code
Bonjour,
J'ai un tableau dans lequel je saisis mensuellement la production par champ.
J'utilise un InputBox et j'aimerais savoir comment je fais pour sortir proprement lorsque je clique sur annuler (ou sur "ok" sans avoir saisi l'information demandée).
Le fichier marche assez bien mais je trouve que mon code est trop long. Je souhaiterais donc avoir une aide sur les moyens de le reduire.
J'ai tenté de joindre le fichier mais il est trop lourd. Désolé donc de vous coller le code ci-dessous (trop long comme indiqué ci-dessus).
Sub SaisirProduction_Clic()
Dim Mois As Long
Dim Mwengui As Long
Dim Lucina As Long
Dim Mbya As Long
Dim Batanga As Long
Dim Breme As Long
Dim Gombe As Long
Dim Obando As Long
Dim Ogouendjo As Long
Dim Rembokoto As Long
Dim Rembokoto2 As Long
Dim Olende As Long
Dim Olende2 As Long
Dim Turnix As Long
Dim Limande As Long
Dim Mpolunie As Long
Dim Ganga As Long
Dim Oba As Long
Dim Loche As Long
Dim Echira As Long
Dim Moukouti As Long
Dim Niungo As Long
Dim Vanneau As Long
Dim Pelican As Long
Dim Mpolunie2 As Long
Mois = InputBox("Veuillez indiquer la Période de production (Ex. pour janvier, saisir 1)", "Choix de la période de Production")
If Mois = 1 Then
Mwengui = InputBox("Mwengui", "Production de Janvier ")
Range("E7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Janvier ")
Range("E5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Janvier ")
Range("E6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Janvier ")
Range("E14").Value = Batanga
Breme = InputBox("Breme (Ogouendjo)", "Production de Janvier ")
Range("E13").Value = Breme
Gombe = InputBox("Gombe", "Production de Janvier ")
Range("E12").Value = Gombe
Obando = InputBox("Obando", "Production de Janvier ")
Range("E10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Janvier ")
Range("E11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Janvier ")
Range("E19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Janvier ")
Range("E16").Value = Olende
Ganga = InputBox("Ganga", "Production de Janvier ")
Range("E22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Janvier ")
Range("E17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Janvier ")
Range("E18").Value = Turnix
Limande = InputBox("Limande", "Production de Janvier ")
Range("E20").Value = Limande
Oba = InputBox("Oba", "Production de Janvier ")
Range("E15").Value = Oba
Loche = InputBox("Loche", "Production de Janvier ")
Range("E21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Janvier ")
Range("E23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Janvier ")
Range("E25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Janvier ")
Range("E24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Janvier ")
Range("E26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Janvier ")
Range("E27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Janvier ")
Range("E28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Janvier ")
Range("E29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Janvier ")
Range("E8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Janvier ")
Range("E9").Value = Vanneau
ElseIf Mois = 2 Then
Mwengui = InputBox("Mwengui", "Production de Février ")
Range("F7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Février ")
Range("F5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Février ")
Range("F6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Février ")
Range("F14").Value = Batanga
Breme = InputBox("Breme (Ogouendjo)", "Production de Février ")
Range("F13").Value = Breme
Gombe = InputBox("Gombe", "Production de Février ")
Range("F12").Value = Gombe
Obando = InputBox("Obando", "Production de Février ")
Range("F10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Février ")
Range("F11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Février ")
Range("F19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Février ")
Range("F16").Value = Olende
Ganga = InputBox("Ganga", "Production de Février ")
Range("F22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Février ")
Range("F17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Février ")
Range("F18").Value = Turnix
Limande = InputBox("Limande", "Production de Février ")
Range("F20").Value = Limande
Oba = InputBox("Oba", "Production de Février ")
Range("F15").Value = Oba
Loche = InputBox("Loche", "Production de Février ")
Range("F21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Février ")
Range("F23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Février ")
Range("F25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Février ")
Range("F24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Février ")
Range("F26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Février ")
Range("F27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Février ")
Range("F28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Février ")
Range("F29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Février ")
Range("F8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Février ")
Range("F9").Value = Vanneau
ElseIf Mois = 3 Then
Mwengui = InputBox("Mwengui", "Production de Mars ")
Range("G7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Mars ")
Range("G5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Mars ")
Range("G6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Mars ")
Range("G14").Value = Batanga
Breme = InputBox("Breme (Ogouendjo)", "Production de Mars ")
Range("G13").Value = Breme
Gombe = InputBox("Gombe", "Production de Mars ")
Range("G12").Value = Gombe
Obando = InputBox("Obando", "Production de Mars ")
Range("G10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Mars ")
Range("G11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Mars ")
Range("G19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Mars ")
Range("G16").Value = Olende
Ganga = InputBox("Ganga", "Production de Mars ")
Range("G22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Mars ")
Range("G17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Mars ")
Range("G18").Value = Turnix
Limande = InputBox("Limande", "Production de Mars ")
Range("G20").Value = Limande
Oba = InputBox("Oba", "Production de Mars ")
Range("G15").Value = Oba
Loche = InputBox("Loche", "Production de Mars ")
Range("G21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Mars ")
Range("G23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Mars ")
Range("G25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Mars ")
Range("G24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Mars ")
Range("G26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Mars ")
Range("G27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Mars ")
Range("G28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Mars ")
Range("G29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Mars ")
Range("G8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Mars ")
Range("G9").Value = Vanneau
ElseIf Mois = 4 Then
Mwengui = InputBox("Mwengui", "Production de Avril ")
Range("H7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Avril ")
Range("H5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Avril ")
Range("H6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Avril ")
Range("H14").Value = Batanga
Breme = InputBox("Breme (Ogouendjo)", "Production de Avril ")
Range("H13").Value = Breme
Gombe = InputBox("Gombe", "Production de Avril ")
Range("H12").Value = Gombe
Obando = InputBox("Obando", "Production de Avril ")
Range("H10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Avril ")
Range("H11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Avril ")
Range("H19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Avril ")
Range("H16").Value = Olende
Ganga = InputBox("Ganga", "Production de Avril ")
Range("H22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Avril ")
Range("H17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Avril ")
Range("H18").Value = Turnix
Limande = InputBox("Limande", "Production de Avril ")
Range("H20").Value = Limande
Oba = InputBox("Oba", "Production de Avril ")
Range("H15").Value = Oba
Loche = InputBox("Loche", "Production de Avril ")
Range("H21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Avril ")
Range("H23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Avril ")
Range("H25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Avril ")
Range("H24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Avril ")
Range("H26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Avril ")
Range("H27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Avril ")
Range("H28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Avril ")
Range("H29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Avril ")
Range("H8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Avril ")
Range("H9").Value = Vanneau
ElseIf Mois = 5 Then
Mwengui = InputBox("Mwengui", "Production de Mai ")
Range("I7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Mai ")
Range("I5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Mai ")
Range("I6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Mai ")
Range("I14").Value = Batanga
Breme = InputBox("Breme", "Production de Mai ")
Range("I13").Value = Breme
Gombe = InputBox("Gombe", "Production de Mai ")
Range("I12").Value = Gombe
Obando = InputBox("Obando", "Production de Mai ")
Range("I10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Mai ")
Range("I11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Mai ")
Range("I19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Mai ")
Range("I16").Value = Olende
Ganga = InputBox("Ganga", "Production de Mai ")
Range("I22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Mai ")
Range("I17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Mai ")
Range("I18").Value = Turnix
Limande = InputBox("Limande", "Production de Mai ")
Range("I20").Value = Limande
Oba = InputBox("Oba", "Production de Mai ")
Range("I15").Value = Oba
Loche = InputBox("Loche", "Production de Mai ")
Range("I21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Mai ")
Range("I23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Mai ")
Range("I25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Mai ")
Range("I24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Mai ")
Range("I26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Mai ")
Range("I27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Mai ")
Range("I28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Mai ")
Range("I29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Mai ")
Range("I8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Mai ")
Range("I9").Value = Vanneau
ElseIf Mois = 6 Then
Mwengui = InputBox("Mwengui", "Production de Juin ")
Range("J7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Juin ")
Range("J5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Juin ")
Range("J6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Juin ")
Range("J14").Value = Batanga
Breme = InputBox("Breme", "Production de Juin ")
Range("J13").Value = Breme
Gombe = InputBox("Gombe", "Production de Juin ")
Range("J12").Value = Gombe
Obando = InputBox("Obando", "Production de Juin ")
Range("J10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Juin ")
Range("J11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Juin ")
Range("J19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Juin ")
Range("J16").Value = Olende
Ganga = InputBox("Ganga", "Production de Juin ")
Range("J22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Juin ")
Range("J17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Juin ")
Range("J18").Value = Turnix
Limande = InputBox("Limande", "Production de Juin ")
Range("J20").Value = Limande
Oba = InputBox("Oba", "Production de Juin ")
Range("J15").Value = Oba
Loche = InputBox("Loche", "Production de Juin ")
Range("J21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Juin ")
Range("J23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Juin ")
Range("J25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Juin ")
Range("J24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Juin ")
Range("J26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Juin ")
Range("J27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Juin ")
Range("J28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Juin ")
Range("J29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Juin ")
Range("J8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Juin ")
Range("J9").Value = Vanneau
ElseIf Mois = 7 Then
Mwengui = InputBox("Mwengui", "Production de Juillet ")
Range("K7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Juillet ")
Range("K5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Juillet ")
Range("K6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Juillet ")
Range("K14").Value = Batanga
Breme = InputBox("Breme", "Production de Juillet ")
Range("K13").Value = Breme
Gombe = InputBox("Gombe", "Production de Juillet ")
Range("K12").Value = Gombe
Obando = InputBox("Obando", "Production de Juillet ")
Range("K10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Juillet ")
Range("K11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Juillet ")
Range("K19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Juillet ")
Range("K16").Value = Olende
Ganga = InputBox("Ganga", "Production de Juillet ")
Range("K22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Juillet ")
Range("K17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Juillet ")
Range("K18").Value = Turnix
Limande = InputBox("Limande", "Production de Juillet ")
Range("K20").Value = Limande
Oba = InputBox("Oba", "Production de Juillet ")
Range("K15").Value = Oba
Loche = InputBox("Loche", "Production de Juillet ")
Range("K21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Juillet ")
Range("K23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Juillet ")
Range("K25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Juillet ")
Range("K24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Juillet ")
Range("K26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Juillet ")
Range("K27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Juillet ")
Range("K28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Juillet ")
Range("K29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Juillet ")
Range("K8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Juillet ")
Range("K9").Value = Vanneau
ElseIf Mois = 8 Then
Mwengui = InputBox("Mwengui", "Production de Août ")
Range("L7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Août ")
Range("L5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Août ")
Range("L6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Août ")
Range("L14").Value = Batanga
Breme = InputBox("Breme", "Production de Août ")
Range("L13").Value = Breme
Gombe = InputBox("Gombe", "Production de Août ")
Range("L12").Value = Gombe
Obando = InputBox("Obando", "Production de Août ")
Range("L10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Août ")
Range("L11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Août ")
Range("L19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Août ")
Range("L16").Value = Olende
Ganga = InputBox("Ganga", "Production de Août ")
Range("L22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Août ")
Range("L17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Août ")
Range("L18").Value = Turnix
Limande = InputBox("Limande", "Production de Août ")
Range("L20").Value = Limande
Oba = InputBox("Oba", "Production de Août ")
Range("L15").Value = Oba
Loche = InputBox("Loche", "Production de Août ")
Range("L21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Août ")
Range("L23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Août ")
Range("L25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Août ")
Range("L24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Août ")
Range("L26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Août ")
Range("L27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Août ")
Range("L28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Août ")
Range("L29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Août ")
Range("L8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Août ")
Range("L9").Value = Vanneau
ElseIf Mois = 9 Then
Mwengui = InputBox("Mwengui", "Production de Septembre ")
Range("M7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Septembre ")
Range("M5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Septembre ")
Range("M6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Septembre ")
Range("M14").Value = Batanga
Breme = InputBox("Breme", "Production de Septembre ")
Range("M13").Value = Breme
Gombe = InputBox("Gombe", "Production de Septembre ")
Range("M12").Value = Gombe
Obando = InputBox("Obando", "Production de Septembre ")
Range("M10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Septembre ")
Range("M11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Septembre ")
Range("M19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Septembre ")
Range("M16").Value = Olende
Ganga = InputBox("Ganga", "Production de Septembre ")
Range("M22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Septembre ")
Range("M17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Septembre ")
Range("M18").Value = Turnix
Limande = InputBox("Limande", "Production de Septembre ")
Range("M20").Value = Limande
Oba = InputBox("Oba", "Production de Septembre ")
Range("M15").Value = Oba
Loche = InputBox("Loche", "Production de Septembre ")
Range("M21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Septembre ")
Range("M23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Septembre ")
Range("M25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Septembre ")
Range("M24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Septembre ")
Range("M26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Septembre ")
Range("M27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Septembre ")
Range("M28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Septembre ")
Range("M29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Septembre ")
Range("M8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Septembre ")
Range("M9").Value = Vanneau
ElseIf Mois = 10 Then
Mwengui = InputBox("Mwengui", "Production de Octobre ")
Range("N7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Octobre ")
Range("N5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Octobre ")
Range("N6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Octobre ")
Range("N14").Value = Batanga
Breme = InputBox("Breme", "Production de Octobre ")
Range("N13").Value = Breme
Gombe = InputBox("Gombe", "Production de Octobre ")
Range("N12").Value = Gombe
Obando = InputBox("Obando", "Production de Octobre ")
Range("N10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Octobre ")
Range("N11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Octobre ")
Range("N19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Octobre ")
Range("N16").Value = Olende
Ganga = InputBox("Ganga", "Production de Octobre ")
Range("N22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Octobre ")
Range("N17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Octobre ")
Range("N18").Value = Turnix
Limande = InputBox("Limande", "Production de Octobre ")
Range("N20").Value = Limande
Oba = InputBox("Oba", "Production de Octobre ")
Range("N15").Value = Oba
Loche = InputBox("Loche", "Production de Octobre ")
Range("N21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Octobre ")
Range("N23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Octobre ")
Range("N25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Octobre ")
Range("N24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Octobre ")
Range("N26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Octobre ")
Range("N27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Octobre ")
Range("N28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Octobre ")
Range("N29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Octobre ")
Range("N8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Octobre ")
Range("N9").Value = Vanneau
ElseIf Mois = 11 Then
Mwengui = InputBox("Mwengui", "Production de Novembre ")
Range("O7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Novembre ")
Range("O5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Novembre ")
Range("O6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Novembre ")
Range("O14").Value = Batanga
Breme = InputBox("Breme", "Production de Novembre ")
Range("O13").Value = Breme
Gombe = InputBox("Gombe", "Production de Novembre ")
Range("O12").Value = Gombe
Obando = InputBox("Obando", "Production de Novembre ")
Range("O10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Novembre ")
Range("O11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Novembre ")
Range("O19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Novembre ")
Range("O16").Value = Olende
Ganga = InputBox("Ganga", "Production de Novembre ")
Range("O22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Novembre ")
Range("O17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Novembre ")
Range("O18").Value = Turnix
Limande = InputBox("Limande", "Production de Novembre ")
Range("O20").Value = Limande
Oba = InputBox("Oba", "Production de Novembre ")
Range("O15").Value = Oba
Loche = InputBox("Loche", "Production de Novembre ")
Range("O21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Novembre ")
Range("O23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Novembre ")
Range("O25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Novembre ")
Range("O24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Novembre ")
Range("O26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Novembre ")
Range("O27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Novembre ")
Range("O28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Novembre ")
Range("O29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Novembre ")
Range("O8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Novembre ")
Range("O9").Value = Vanneau
ElseIf Mois = 12 Then
Mwengui = InputBox("Mwengui", "Production de Décembre ")
Range("P7").Value = Mwengui
Lucina = InputBox("Lucina", "Production de Décembre ")
Range("P5").Value = Lucina
Mbya = InputBox("Mbya", "Production de Décembre ")
Range("P6").Value = Mbya
Batanga = InputBox("Batanga", "Production de Décembre ")
Range("P14").Value = Batanga
Breme = InputBox("Breme", "Production de Décembre ")
Range("P13").Value = Breme
Gombe = InputBox("Gombe", "Production de Décembre ")
Range("P12").Value = Gombe
Obando = InputBox("Obando", "Production de Décembre ")
Range("P10").Value = Obando
Ogouendjo = InputBox("Ogouendjo", "Production de Décembre ")
Range("P11").Value = Ogouendjo
Rembokotto = InputBox("Rembo Kotto (Ogouendjo)", "Production de Décembre ")
Range("P19").Value = Rembokotto
Olende = InputBox("Olende (Ogouendjo)", "Production de Décembre ")
Range("P16").Value = Olende
Ganga = InputBox("Ganga", "Production de Décembre ")
Range("P22").Value = Ganga
Mpolunie = InputBox("Mpolunie", "Production de Décembre ")
Range("P17").Value = Mpolunie
Turnix = InputBox("Turnix", "Production de Décembre ")
Range("P18").Value = Turnix
Limande = InputBox("Limande", "Production de Décembre ")
Range("P20").Value = Limande
Oba = InputBox("Oba", "Production de Décembre ")
Range("P15").Value = Oba
Loche = InputBox("Loche", "Production de Décembre ")
Range("P21").Value = Loche
Olende2 = InputBox("Olende (Olende)", "Production de Décembre ")
Range("P23").Value = Olende2
Rembokotto2 = InputBox("Rembo Kotto (Olende)", "Production de Décembre ")
Range("P25").Value = Rembokotto2
Breme2 = InputBox("Breme (Olende)", "Production de Décembre ")
Range("P24").Value = Breme2
Mpolunie2 = InputBox("Mpolunie (Olende)", "Production de Décembre ")
Range("P26").Value = Mpolunie2
Echira = InputBox("Echira", "Production de Décembre ")
Range("P27").Value = Echira
Moukouti = InputBox("Moukouti", "Production de Décembre ")
Range("P28").Value = Moukouti
Niungo = InputBox("Niungo", "Production de Décembre ")
Range("P29").Value = Niungo
Pelican = InputBox("Pelican", "Production de Décembre ")
Range("P8").Value = Pelican
Vanneau = InputBox("Vanneau", "Production de Décembre ")
Range("P9").Value = Vanneau
End Sub
Merci d'avance pour votre aide.
PMALONG
Bonjour Pmalong,
OMG ça pique les yeux comme ça... Utilise les balises de code pour remettre ça en forme pour que ça soit lisible!
(au dessus de la zone ds laquelle tu tapes ton message, les boutons verts!)
Alors moi je te propose un truc du style :
.....
Dim TxtInpt as String
Mois = InputBox("Veuillez indiquer la Période de production (Ex. pour janvier, saisir 1)", "Choix de la période de Production")
InputProdz Mois
.....
sub InputProdz(Mois as Integer)
TxtInpt = TxtMois(Mois)
Mwengui = InputBox("Mwengui", TxtInpt)
If Mwengui = vbCancel then exit sub
Cells(7, 4+Mois).Value = Mwengui
Lucina = InputBox("Lucina", TxtInpt)
If Lucina= vbCancel then exit sub
Cells(5, 4+Mois).Value = Lucina
.... sur tous tes sites
end sub
Function TxtMois(Mois as integer)
Txtmois = "Production de " & Format(Mois, "mmm")
end function
Merci pour la réponse.
En ajoutant If Lucina = vbCancel Then Exit Sub cela revient à allonger encore un peu plus mon code ?
Cdt,
PMALONG
PMALONG a écrit :J'utilise un "InputBox" et j'aimerais savoir comment je fais pour sortir proprement lorsque je clique sur annuler (ou sur "ok" sans avoir saisi l'information demandée).
If (Lucina = vbCancel or Lucina =vbOk) Then Exit Sub
pour intégrer le OK aussi!
Oui ça rallonge un peu mais si tu veux pouvoir quitter le programme facilement à chaque inputbox qui s'affiche il me semble que c'est le plus efficace...
Et tu n'as déjà plus 12 fois tes X sites de production ce qui rend considérablement plus lisible ton programme!
Bonjour
Une autre idée à tester
Edit : Suppression de la macro : Non adaptée
Bonjour Banzaï,
j'aime toujours autant te lire, j'apprend plein de choses!
Petite remarque avant mes "questions", il entre les productions dans la colonne E que pour le mois de Janvier et décale en F pour Février et ainsi de suite, il faudrait donc pouvoir décaler la ListePlage mais comme c'est en texte je sais pas comment faire (simplement)...
Ensuite, je connaissais pas Split, mais c'est pas mal du tout et surtout c'est quoi le Application.Proper?
Bonjour
Merci Reuk
zavèpavu
Application.Proper() correspond à la fonction NOMPROPRE()
Extrait de l'aide
Met en majuscule la première lettre de chaque chaîne de caractères et toute lettre d'un texte qui suit un caractère non alphabétique. Toutes les autres lettres sont converties en lettres minuscules
Je l'utilise pour marquer le mois avec la 1ère lettre en majuscule (zavèvu)
Modification du code
Option Explicit
Sub SaisirProduction_Clic()
Dim ListeNom() As String
Dim LaLigne()
Dim Rep
Dim I As Integer
ListeNom = Split("Mwengui,Lucina,Mbya,Batanga,Breme (Ogouendjo),Gombe,Obando,Ogouendjo,Rembo Kotto (Ogouendjo),Olende (Ogouendjo)," & _
"Ganga,Mpolunie,Turnix,Limande,Oba,Loche,Olende (Olende),Rembo Kotto (Olende),Breme (Olende),Mpolunie (Olende),Echira," & _
"Moukouti,Niungo,Pelican,Vanneau", ",")
LaLigne = Array(7, 5, 6, 14, 13, 12, 10, 11, 19, 16, 22, 17, 18, 20, 15, 21, 23, 25, 24, 26, 27, 28, 29, 8, 9)
mois = InputBox("Veuillez indiquer la Période de production (Ex. pour janvier, saisir 1)", "Choix de la période de Production")
If mois < 1 Or mois > 12 Then Exit Sub
For I = 0 To UBound(ListeNom)
Rep = InputBox(ListeNom(I), "Production de " & Application.Proper(MonthName(mois)))
If Rep = "" Then Exit Sub
Cells(LaLigne(I), 4 + mois) = Val(Replace(Rep, ",", "."))
Next I
End Sub
Perfecto! Merci tonton Banzaï!
Bonjour,
J'ai eu une urgence qui m'a éloigné de mon ordinteur pendant quelques jours.
Un grand merci à Banzai64 pour sa solution magique. Ce que j'ai fait avec des centaines de lignes est résumé à moins de 20 lignes. J'ai vraiment du chemin à faire dans mon apprentissage du VBA.
Merci encore.