Bonjour à tous.
Je recherche une formulation de condition pour exécution d'une macro.
La condition est la suivante :
je lance une macro exécutable par bouton suivant la position du curseur.
et pour pouvoir l'exécuté, je veut vérifié que la ligne ou ce trouve le curseur est bien comprise entre deux ligne haute et basse.
Dans la ligne haute fixe une cellule est nommé si besoin ou avec une contenu.
Dans la ligne basse variable une cellule est nommé si besoin ou avec une contenu.
Voici pour précision mon tableau
Code :
Pour illustration de mon fichier:
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 Sub supp_ligne_2() Dim i As Integer Dim j As Integer Dim k As Range Dim l As Range Dim m As Range ActiveSheet.Unprotect i = ActiveCell.Row j = i - 1 If ActiveSheet.Name <> "Etude" And ActiveSheet.Name <> "Etude opt" Then MsgBox ("Selection non valide pour cette opération") Else: k = Cells("Deb").Row l = Cells("Fin").Row If i < k And i > l Then MsgBox ("Selection non valide pour cette opération") Else: Rows(i & ":" & i).Delete Shift:=xlUp Range("B" & j).Select 'une erreur de mise en page apparait si l'action ce passe sous un chapitre 'remise en forme si sous chapitre If ((Range("B" & j).Font.Bold = True) And (Range("B" & j).Interior.ColorIndex = 34)) Then With Range("B" & j & ":P" & j) With .Font .Bold = True .ColorIndex = 3 End With With .Borders(xlEdgeTop) .LineStyle = xlDouble .Weight = xlThick .ColorIndex = xlAutomatic End With With .Borders(xlEdgeBottom) .LineStyle = xlDouble .Weight = xlThick .ColorIndex = xlAutomatic End With With .Borders(xlEdgeRight) .LineStyle = xlDouble .Weight = xlThick .ColorIndex = xlAutomatic End With With .Borders(xlEdgeLeft) .LineStyle = xlDouble .Weight = xlThick .ColorIndex = xlAutomatic End With With .Interior .ColorIndex = 34 .Pattern = xlSolid .PatternColorIndex = 49 End With Range("B" & j).Font.ColorIndex = 1 End With End If Range("B" & i).Select End If ActiveSheet.Protect , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True End If End Sub
Doc1.doc
Merci pour votre aide et votre temps.
Crdl
Partager