Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- 'Option Explicit
- '=================================================================================================
- Dim vList1, vList2
- '==============================================='
- Sub allList(a As Long)
- Dim fm, gm
- Dim n As Variant
- With Sheets("Matrice BXL")
- fm = Application.Match("Sélectionner paquet sol", .Range("D:D"), 0)
- gm = Application.Match("Sélectionner paquet eau", .Range("D:D"), 0)
- n = .Range("D:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
- If a = 1 Then
- 'LIST 1 location
- vList1 = .Range("D" & fm & ":D" & gm - 1)
- ElseIf a = 2 Then
- 'LIST 2 location
- vList2 = .Range("D" & gm & ":D" & n)
- End If
- End With
- End Sub
- Sub toFilter(cbo As Object, vList)
- Dim dar As Object, i As Long
- Dim z, x
- If IsEmpty(vList) Then
- If Right(cbo.Name, 1) < 6 And Right(cbo.Name, 1) > 0 Then
- Call allList(1)
- Else
- Call allList(2)
- End If
- End If
- With cbo
- If .Value <> "" And IsError(Application.Match(.Value, vList, 0)) Then
- Set dar = CreateObject("System.Collections.ArrayList")
- For i = LBound(vList) To UBound(vList)
- dar.Add vList(i, 1)
- Next
- For Each x In Split(.Value, ",")
- x = Trim(x)
- If Len(x) > 0 Then
- For i = dar.Count - 1 To 0 Step -1
- If InStr(1, dar(i), x, vbTextCompare) = 0 Then dar.RemoveAt i
- Next
- End If
- Next
- .List = dar.Toarray()
- .DropDown
- End If
- End With
- End Sub
- Sub setCombobox(cbo As Object)
- With cbo
- .MatchEntry = fmMatchEntryNone
- '.Value = ""
- '.LinkedCell = ""
- '.ListRows = 10 'show how many item
- .Height = 20
- .Width = 200
- End With
- End Sub
- Sub setCombobox_A(cbo As Object)
- With cbo
- .MatchEntry = fmMatchEntryNone
- ' .Value = ""
- ' .LinkedCell = ""
- '.ListRows = 10 'show how many item
- .Height = 13
- .Width = 170
- End With
- End Sub
- Sub fillEmptyList(cbo1 As Object)
- If IsEmpty(vList) Then
- If Val(cbo1.Name) < 6 Then Call allList(1)
- Else
- Call allList(2)
- End If
- End If
- End Sub
- '============== ComboBox1 ====================
- Private Sub ComboBox1_GotFocus()
- Call setCombobox(ComboBox1)
- Call allList(1) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox1_LostFocus()
- Call setCombobox_A(ComboBox1)
- End Sub
- Private Sub ComboBox1_Change()
- Call toFilter(ComboBox1, vList1) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox1_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList1) Then Call allList(1)
- ComboBox1.List = vList1
- End Sub
- '=============================================================================
- '============== ComboBox2 ====================
- Private Sub ComboBox2_GotFocus()
- Call setCombobox(ComboBox2)
- Call allList(1) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox2_LostFocus()
- Call setCombobox_A(ComboBox2)
- End Sub
- Private Sub ComboBox2_Change()
- Call toFilter(ComboBox2, vList1) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox2_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList1) Then Call allList(1)
- ComboBox2.List = vList1
- End Sub
- '=============================================================================
- '============== ComboBox3 ====================
- Private Sub ComboBox3_GotFocus()
- Call setCombobox(ComboBox3)
- Call allList(1) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox3_LostFocus()
- Call setCombobox_A(ComboBox3)
- End Sub
- Private Sub ComboBox3_Change()
- Call toFilter(ComboBox3, vList1) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox3_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList1) Then Call allList(1)
- ComboBox3.List = vList1
- End Sub
- '=============================================================================
- '============== ComboBox4 ====================
- Private Sub ComboBox4_GotFocus()
- Call setCombobox(ComboBox4)
- Call allList(1) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox4_LostFocus()
- Call setCombobox_A(ComboBox4)
- End Sub
- Private Sub ComboBox4_Change()
- Call toFilter(ComboBox4, vList1) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox4_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList1) Then Call allList(1)
- ComboBox4.List = vList1
- End Sub
- '=============================================================================
- '============== ComboBox5 ====================
- Private Sub ComboBox5_GotFocus()
- Call setCombobox(ComboBox5)
- Call allList(1) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox5_LostFocus()
- Call setCombobox_A(ComboBox5)
- End Sub
- Private Sub ComboBox5_Change()
- Call toFilter(ComboBox5, vList1) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox5_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList1) Then Call allList(1)
- ComboBox5.List = vList1
- End Sub
- '=============================================================================
- '============== ComboBox6 ====================
- Private Sub ComboBox6_GotFocus()
- Call setCombobox(ComboBox6)
- Call allList(2) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox6_LostFocus()
- Call setCombobox_A(ComboBox6)
- End Sub
- Private Sub ComboBox6_Change()
- Call toFilter(ComboBox6, vList2) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox6_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList2) Then Call allList(2)
- If ComboBox6.Value = vbNullString Then ComboBox6.List = vList2
- End Sub
- '=============================================================================
- '=============================================================================
- '============== ComboBox7 ====================
- Private Sub ComboBox7_GotFocus()
- Call setCombobox(ComboBox7)
- Call allList(2) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox7_LostFocus()
- Call setCombobox_A(ComboBox7)
- End Sub
- Private Sub ComboBox7_Change()
- Call toFilter(ComboBox7, vList2) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox7_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList2) Then Call allList(2)
- ComboBox7.List = vList2
- End Sub
- '=============================================================================
- '============== ComboBox8 ====================
- Private Sub ComboBox8_GotFocus()
- Call setCombobox(ComboBox8)
- Call allList(2) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox8_LostFocus()
- Call setCombobox_A(ComboBox8)
- End Sub
- Private Sub ComboBox8_Change()
- Call toFilter(ComboBox8, vList2) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox8_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList2) Then Call allList(2)
- ComboBox8.List = vList2
- End Sub
- '=============================================================================
- '============== ComboBox9 ====================
- Private Sub ComboBox9_GotFocus()
- Call setCombobox(ComboBox9)
- Call allList(2) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox9_LostFocus()
- Call setCombobox_A(ComboBox9)
- End Sub
- Private Sub ComboBox9_Change()
- Call toFilter(ComboBox9, vList2) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox9_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList2) Then Call allList(2)
- ComboBox9.List = vList2
- End Sub
- '=============================================================================
- '============== ComboBox10 ====================
- Private Sub ComboBox10_GotFocus()
- Call setCombobox(ComboBox10)
- Call allList(2) '>>> 1 for LIST 1, 2 for LIST 2
- End Sub
- Private Sub ComboBox10_LostFocus()
- Call setCombobox_A(ComboBox10)
- End Sub
- Private Sub ComboBox10_Change()
- Call toFilter(ComboBox10, vList2) '>>> vList1 for LIST 1, vList2 for LIST 2
- End Sub
- Private Sub ComboBox10_DropButtonClick()
- '>>> vList1 for LIST 1, vList2 for LIST 2
- If IsEmpty(vList2) Then Call allList(2)
- ComboBox10.List = vList2
- End Sub
- '=============================================================================
- 'pour réinitialiser la macro
- Private Sub CommandButton1_Click()
- Application.EnableEvents = True
- End Sub
- 'fonction pour masquer les lignes en fonction du type choisi. Les lignes ont reçu des noms, pour que ajout lignes possible
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Not Intersect(Target, Range("data1:data6")) Is Nothing Then
- Cells.EntireRow.Hidden = False
- Select Case Range("data1")
- Case "RECONNAISSANCE DE L'ÉTAT DU SOL (RES)"
- Range("E_RES_00,E_ED_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "ÉTUDE DÉTAILLÉE (ED)"
- Range("E_RES_00:E_ED_00,E_ER_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "ÉTUDE DE RISQUE (ER)"
- Range("E_RES_00:E_ER_00,E_RES_ED_ER_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "RECONNAISSANCE + ÉTUDE DÉTAILLÉE (RES-ED)"
- Range("E_RES_00,E_ED_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "ÉTUDE DÉTAILLÉE + ÉTUDE DE RISQUE (ED-ER)"
- Range("E_RES_00:E_ER_00,E_RES_ED_ER_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "RECONNAISSANCE + ÉTUDE DÉTAILLÉE + ÉTUDE DE RISQUE (RES-ED-ER)"
- Range("E_RES_00:E_RES_ED_ER_00,E_PA_PGR_00:E_TV_11,D_01:M_06,L_S_13").EntireRow.Hidden = True
- Case "PROJET DE GESTION DE RISQUE (PGR)"
- Range("E_RES_00:E_PA_PGR_00,E_PA_PGR_12:E_PA_PGR_17,E_SUIVI_00:E_TV_11,L_S_13").EntireRow.Hidden = True
- Case "PROJET DE GESTION DE RISQUE (PGR) + SUIVI"
- Range("E_RES_00:E_PA_PGR_00,E_SUIVI_00:E_TV_11,L_S_13").EntireRow.Hidden = True
- Case "PROJET D'ASSAINISSEMENT (PA)"
- Range("E_RES_00:E_PA_PGR_00,E_PA_PGR_12:E_PA_PGR_17,E_SUIVI_00:E_TV_11,L_S_13").EntireRow.Hidden = True
- Case "PROJET D'ASSAINISSEMENT (PA) + SUIVI"
- Range("E_RES_00:E_PA_PGR_00,E_SUIVI_00:E_TV_11,L_S_13").EntireRow.Hidden = True
- Case "SUIVI DES TRAVAUX (SUIVI)"
- Range("E_RES_00:E_SUIVI_00,E_TDL_00:E_TV_11,L_S_13").EntireRow.Hidden = True
- Case "TRAITEMENT DE DURÉE LIMITÉE (TDL) + SUIVI"
- Range("E_RES_00:E_TDL_00,E_GF_00:E_TV_11,T_FMan_05:T_FMan_06,T_FMan_10,T_FMec_01:T_FMec_15,T_Car_FMan_10,T_Car_FMec_01:T_Car_FMec_10,T_EchE_01:T_EchE_05,T_GEO_07:T_GEO_08,M_03:M_05,L_S_13:L_E_10").EntireRow.Hidden = True
- Case "ESTIMATION DU MONTANT DE GARANTIE FINANCIÈRE (GF)"
- Range("E_RES_00:E_GF_00,E_TV_00:E_TV_11,X_07:X_10").EntireRow.Hidden = True
- Case "RAPPORT TECHNIQUE BRUXELLOIS (RT)"
- Range("E_RES_00:E_TV_00,T_FMan_05:T_FMan_06,T_FMan_10,T_FMec_08:T_FMec_12,T_FMec_15,T_Car_FMan_10,T_Car_FMec_09,T_TechS_05:T_TechS_06,T_EchE_01:T_EchE_05,T_GEO_07:T_GEO_08,D_01:M_06,L_E_01:L_E_10").EntireRow.Hidden = True
- Case "TECHNISH VERSLAG (TV)"
- Range("E_RES_00:E_TV_00,T_FMan_05:T_FMan_06,T_FMan_10,T_FMec_08:T_FMec_12,T_FMec_15,T_Car_FMan_10,T_Car_FMec_09,T_TechS_05:T_TechS_06,T_EchE_01:T_EchE_05,T_GEO_07:T_GEO_08,D_01:M_06,L_E_01:L_E_10").EntireRow.Hidden = True
- End Select
- Select Case Range("data2")
- Case "POSTES STANDARD UNIQUEMENT"
- Range("T_FMan_09,T_FMan_10,T_TechS_02,T_TechS_03,T_TechS_05:T_TechS_07,T_GEO_09,T_GEO_12").EntireRow.Hidden = True
- End Select
- Select Case Range("data3")
- Case "SOL"
- Range("T_FMan_05,T_FMan_06,T_FMan_10,T_FMec_08:T_FMec_12,T_FMec_15,T_Car_FMan_10,T_Car_FMec_09,T_EchE_01:T_EchE_05,T_GEO_07,T_GEO_08,L_E_01:L_E_10").EntireRow.Hidden = True
- Case "EAU"
- Range("T_TechS_02:T_TechS_04,L_S_01:L_S_13").EntireRow.Hidden = True
- End Select
- Select Case Range("data4")
- Case "MANUEL"
- Range("T_FMec_01:T_FMec_15,T_Car_FMec_01:T_Car_FMec_10").EntireRow.Hidden = True
- Case "MECANIQUE"
- Range("T_FMan_01:T_FMan_10,T_Car_FMan_01:T_Car_FMan_11").EntireRow.Hidden = True
- End Select
- Select Case Range("data5")
- Case "SANS TRAVAUX DE TERRAIN"
- Range("X_07:X_10").EntireRow.Hidden = True
- Case "AVEC TRAVAUX DE TERRAIN POUR ER (juste nivellement/perméa)"
- Range("T_FMan_01:T_GEO_01,T_GEO_05,T_GEO_09:T_GEO_10,T_GEO_12:T_GEO_13,D_01:X_10").EntireRow.Hidden = True
- End Select
- 'masque de la ligne des sélections d'étude en FR-NL selon choix de la langue
- Select Case Range("data6")
- Case "FR"
- Range("X_02,X_04").EntireRow.Hidden = True
- Case "NL"
- Range("X_01,X_03").EntireRow.Hidden = True
- End Select
- End If
- 'menu dropdown list bilingues. Les cellules avec dropdown ont reçues des noms (dataX). Attention cohérence noms dans les listes (ray etc.) et les 'Case'
- Dim ray As Variant, n As Long, ac As Long, Txt As String, nStr As String
- Application.EnableEvents = False
- ReDim ray(1 To 4, 1 To 2)
- ReDim nray(1 To 8, 1 To 2)
- If Target.Address = Range("data6").Address Then
- ray(1, 1) = "Commande des études de sol antérieures (étude)"
- ray(1, 2) = "Bestelling eerdere bodemonderzoeken (studie)"
- ray(2, 1) = "Bestelling eerdere bodemonderzoeken (studie)"
- ray(2, 2) = "Commande des études de sol antérieures (étude)"
- ray(3, 1) = "Commande des études de sol antérieures (dossier)"
- ray(3, 2) = "Bestelling eerdere bodemonderzoeken (dossier)"
- ray(4, 1) = "Bestelling eerdere bodemonderzoeken (dossier)"
- ray(4, 2) = "Commande des études de sol antérieures (dossier)"
- Txt = Range("data7").Value
- For n = 1 To UBound(ray, 1)
- If ray(n, 1) = Txt Then
- Txt = ray(n, 2)
- Exit For
- End If
- Next n
- Select Case Target.Value
- Case "FR": nStr = "Sélectionner étude de sol antérieure (étude vs. dossier),Commande des études de sol antérieures (étude),Commande des études de sol antérieures (dossier)"
- Case "NL": nStr = "Sélectionner étude de sol antérieure (étude vs. dossier),Bestelling eerdere bodemonderzoeken (dossier),Bestelling eerdere bodemonderzoeken (studie)"
- End Select
- With Range("data7").Validation
- .Delete
- .Add Type:=xlValidateList, Formula1:=nStr
- End With
- Range("data7").Value = Txt
- nray(1, 1) = "Mobilisation carotteuse (< ou = 6 carottages)"
- nray(1, 2) = "Mobilisatie kernboormachine (< of = 6 boringen)"
- nray(2, 1) = "Mobilisatie kernboormachine (< of = 6 boringen)"
- nray(2, 2) = "Mobilisation carotteuse (< ou = 6 carottages)"
- nray(3, 1) = "Mobilisation carotteuse (> 6 carottages)"
- nray(3, 2) = "Mobilisatie kernboormachine (> 6 boringen)"
- nray(4, 1) = "Mobilisatie kernboormachine (> 6 boringen)"
- nray(4, 2) = "Mobilisation carotteuse (> 6 carottages)"
- nray(5, 1) = "Mobilisation carotteuse (> 15 carottages)"
- nray(5, 2) = "Mobilisatie kernboormachine (> 15 boringen)"
- nray(6, 1) = "Mobilisatie kernboormachine (> 15 boringen)"
- nray(6, 2) = "Mobilisation carotteuse (> 15 carottages)"
- nray(7, 1) = "Mobilisation carotteuse (> 20 carottages)"
- nray(7, 2) = "Mobilisatie kernboormachine (> 20 boringen)"
- nray(8, 1) = "Mobilisatie kernboormachine (> 20 boringen)"
- nray(8, 2) = "Mobilisation carotteuse (> 20 carottages)"
- Txt = Range("data8").Value
- For n = 1 To UBound(nray, 1)
- If nray(n, 1) = Txt Then
- Txt = nray(n, 2)
- Exit For
- End If
- Next n
- Select Case Target
- Case "FR": nStr = "Sélectionner carottage,Mobilisation carotteuse (< ou = 6 carottages),Mobilisation carotteuse (> 6 carottages),Mobilisation carotteuse (> 15 carottages),Mobilisation carotteuse (> 20 carottages)"
- Case "NL": nStr = "Sélectionner carottage,Mobilisatie kernboormachine (< of = 6 boringen),Mobilisatie kernboormachine (> 6 boringen),Mobilisatie kernboormachine (> 15 boringen),Mobilisatie kernboormachine (> 20 boringen)"
- End Select
- With Range("data8").Validation
- .Delete
- .Add Type:=xlValidateList, Formula1:=nStr
- End With
- Range("data8").Value = Txt
- End If
- Application.EnableEvents = True
- End Sub
- Sub toLinkCell()
- ComboBox1.LinkedCell = "Y261"
- ComboBox2.LinkedCell = "Y262"
- ComboBox3.LinkedCell = "Y263"
- ComboBox4.LinkedCell = "Y264"
- ComboBox5.LinkedCell = "Y265"
- ComboBox6.LinkedCell = "Y274"
- ComboBox7.LinkedCell = "Y275"
- ComboBox8.LinkedCell = "Y276"
- ComboBox9.LinkedCell = "Y277"
- ComboBox10.LinkedCell = "Y278"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement