Bonjour

J'ai la chance d'utiliser excel 2003 et je suis donc contraint de développer une macro si je veux disposer d'un visuel plus confortable que celui offert par la fonction mise en forme conditionnelle (conditionnal formating).

Mes connaissances en VBA sont minimes je suis capable de parfois comprendre et de modifier le code très simplement.

J'ai trouvé une macro qui m'intéresse mais je ne parviens pas à l'adapter.

http://chandoo.org/wp/2008/10/14/mor...mats-in-excel/



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
Sub cFormat()
' This is a macro for creating more than 3 conditional formats
' Install this macro (just copy paste this code in to your workbook in a new module
' Define 3 named ranges:
'   data2use: with the data you want to format with more than 3 conditional formats
'   conditions2use: same shape and size as data2use with format conditions for each cell in the data2use, from 1 to n
'   formats2use: this range has n cells each with one format to be used when formatting data2use range
'when done, hit ALT+F8 and run the cFormat() macro
 
    Dim conditions()
 
    ReDim conditions(1 To Range("conditions2use").Count)
    Dim i
 
    i = 1
 
    For Each cell In Range("conditions2use")
        conditions(i) = CInt(cell.Value)
        i = i + 1
    Next cell
 
    i = 1
    For Each cell In Range("data2use")
        Range("formats2use").Cells(conditions(i)).Select
        Selection.Copy
        cell.Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
        i = i + 1
    Next cell
End Sub

il est dit "Define 3 named ranges" --> comment je définit ça?
Est ce que quelqu'un peut aider afin que je comprennne comment on définit une variable en VBA, comment le système comprend l'écriture?

Merci

P