Bonjour
Avec le code suivant je souhaite juste ajouter une cellule a une plage nommée après m'être assurée que cette plage n'est pas vide.
Rien à faire cela ne marche pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim Sc1 As Integer Dim Sc2 As Integer Dim Sc3 As Integer Dim Sc4 As Integer Dim Sc5 As Integer Dim oCellule As Object Dim maplage As Range '******Scenario 1 Set oZOneatestersc1 = Sheets("calculs").Range("f4:f25") For Each oCellule In oZOneatestersc1 If oCellule = "OUI" Then Sc1 = Sc1 + 1 Next oCellule '******Scenario 2 Set oZOneatestersc2 = Sheets("calculs").Range("g4:g25") For Each oCellule In oZOneatestersc2 If oCellule = "OUI" Then Sc2 = Sc2 + 1 Next oCellule '******Scenario 3 Set oZOneatestersc3 = Sheets("calculs").Range("h4:h25") For Each oCellule In oZOneatestersc3 If oCellule = "OUI" Then Sc3 = Sc3 + 1 Next oCellule '******Scenario 4 Set oZOneatestersc4 = Sheets("calculs").Range("i4:i25") For Each oCellule In oZOneatestersc4 If oCellule = "OUI" Then Sc4 = Sc4 + 1 Next oCellule '******Scenario 5 Set oZOneatestersc5 = Sheets("calculs").Range("j4:j25") For Each oCellule In oZOneatestersc5 If oCellule = "OUI" Then Sc5 = Sc5 + 1 Next oCellule If Sc1 > 0 Then Set maplage = Sheets("calculs").Range("f3") If Sc2 > 0 Then If maplage Is Nothing Then Set maplage = Sheets("calculs").Range("g3") Else Set maplage = Union(maplage, Sheets("calculs").Range("g3")) End If If Sc3 > 0 Then If maplage Is Nothing Then Set maplage = Sheets("calculs").Range("h3") Else Set maplage = Union(maplage, Sheets("calculs").Range("h3")) End If If Sc4 > 0 Then If maplage Is Nothing Then Set maplage = Sheets("calculs").Range("i3") Else Set maplage = Application.Union(maplage, Sheets("calculs").Range("i3")) End If If Sc5 > 0 Then If maplage Is Nothing Then Set maplage = Sheets("calculs").Range("j3") Else Set maplage = Union(maplage, Sheets("calculs").Range("j3")) End If ActiveWorkbook.Names("Liste_scenario").Delete ActiveWorkbook.Names.Add Name:="Liste_scenario", RefersTo:=maplage
Partager