Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

explication sur macro

5 réponses
Avatar
Christian Raoux
salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait donné je
les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex
ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0)) Then
ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex
Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex
End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"), 0))
Then

car je la macro ne fonctione plus

merci d'avance

Christian

5 réponses

Avatar
Bourby
Bonjour,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"), 0))
... il est peut-être allergique aux fautes d'orthographe?
(juste pour la blague et sans méchanceté).

En revanche, si tu n'as pas nommé un plage "feriers",
il ne va pas la trouver. Est-ce ça le problème?

Cordialement.

Bourby


"Christian Raoux" a écrit dans le message news:

salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait donné je
les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex
ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0)) Then
ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex
Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex
End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"), 0))
Then

car je la macro ne fonctione plus

merci d'avance

Christian


Avatar
Christian Raoux
salut
il y une plage nommé "feriers" (sans accents)

mais c'est sur cette lique que je voudrais des explications car je ne
comprend pas IsError et Aplication.Match

merci

christian

"Bourby" écrivait news:Oysc3svoDHA.2416
@TK2MSFTNGP10.phx.gbl:

Bonjour,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))

... il est peut-être allergique aux fautes d'orthographe?
(juste pour la blague et sans méchanceté).

En revanche, si tu n'as pas nommé un plage "feriers",
il ne va pas la trouver. Est-ce ça le problème?

Cordialement.

Bourby


"Christian Raoux" a écrit dans le message
news:


salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait donné
je


les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex ElseIf Not
IsError(Application.Match(CLng(MyDate), Range("feriers"), 0)) Then
ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))


Then

car je la macro ne fonctione plus

merci d'avance

Christian







Avatar
isabelle
bonjour Christian,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),

traduction libre:

sinon s'il n'y a pas d'erreur pour trouver l'equivalent (match) de
CLng(MyDate) dans la plage Range("feriers")
alors

CLng(MyDate) une date en format standard
Range("feriers") plage nommé de la feuille de calcul

isabelle


salut
il y une plage nommé "feriers" (sans accents)

mais c'est sur cette lique que je voudrais des explications car je ne
comprend pas IsError et Aplication.Match

merci

christian

"Bourby" écrivait news:Oysc3svoDHA.2416
@TK2MSFTNGP10.phx.gbl:

Bonjour,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))

... il est peut-être allergique aux fautes d'orthographe?
(juste pour la blague et sans méchanceté).

En revanche, si tu n'as pas nommé un plage "feriers",
il ne va pas la trouver. Est-ce ça le problème?

Cordialement.

Bourby


"Christian Raoux" a écrit dans le message
news:


salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait donné
je


les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex ElseIf Not
IsError(Application.Match(CLng(MyDate), Range("feriers"), 0)) Then
ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))


Then

car je la macro ne fonctione plus

merci d'avance

Christian









Avatar
Christian Raoux
Ok merci pour l'explication
mais ça ne marche pas

christian

isabelle écrivait
news::

bonjour Christian,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),

traduction libre:

sinon s'il n'y a pas d'erreur pour trouver l'equivalent (match) de
CLng(MyDate) dans la plage Range("feriers")
alors

CLng(MyDate) une date en format standard
Range("feriers") plage nommé de la feuille de calcul

isabelle


salut
il y une plage nommé "feriers" (sans accents)

mais c'est sur cette lique que je voudrais des explications car je ne
comprend pas IsError et Aplication.Match

merci

christian

"Bourby" écrivait news:Oysc3svoDHA.2416
@TK2MSFTNGP10.phx.gbl:

Bonjour,

ElseIf Not IsError(Application.Match(CLng(MyDate),
Range("feriers"), 0)) ... il est peut-être allergique aux fautes
d'orthographe? (juste pour la blague et sans méchanceté).

En revanche, si tu n'as pas nommé un plage "feriers", il ne va pas
la trouver. Est-ce ça le problème?

Cordialement.

Bourby


"Christian Raoux" a écrit dans le message
news:
salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait
donné je les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex ElseIf Not
IsError(Application.Match(CLng(MyDate), Range("feriers"), 0))
Then ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate),
Range("feriers"), 0)) Then

car je la macro ne fonctione plus

merci d'avance

Christian












Avatar
Bourby
re bonjour,

je ne suispas un grand spécialiste, mais voilà ce qu'il m'en semble:

IsError est une fonction de VBA; elle renvoie une valeur logique
(faux ou vrai ) selon que la méthode (Î qui est entre parenthèses)
s'est exécutée correctement ou non.
L'idée est que si Match ne trouve pas ce qu'il cherche
(maDate convertie en nombre), il retournera une valeur d'erreur, et donc
Iserror(Match....) sera VRAI.

Mais il y a un hic: Match n'est pas une méthode de VBA,
(c'est une fonction d'Excel je crois).
Tu pourrais essayer avec la méthode VBA Find.
Si elle ne trouve rien, elle renvoie une plage vide
(Nothing) et non pas un code d'erreur.
La fonction qui teste si une plage "maCellule" est vide ou pleine
est if range("maCellule") is Nothing.
Il me semble donc que le code correct serait:
ElseIf Not Range("feriers").Find(CLng(MyDate)) is Nothing

N'hésite pas à consulter l'aide de VBA.

Je n'ai plus de temps ce soir, j'espère que tu t'en sortiras.

Cordialement

Bourby




"Christian Raoux" a écrit dans le message news:

salut
il y une plage nommé "feriers" (sans accents)

mais c'est sur cette lique que je voudrais des explications car je ne
comprend pas IsError et Aplication.Match

merci

christian

"Bourby" écrivait news:Oysc3svoDHA.2416
@TK2MSFTNGP10.phx.gbl:

Bonjour,

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))

... il est peut-être allergique aux fautes d'orthographe?
(juste pour la blague et sans méchanceté).

En revanche, si tu n'as pas nommé un plage "feriers",
il ne va pas la trouver. Est-ce ça le problème?

Cordialement.

Bourby


"Christian Raoux" a écrit dans le message
news:


salut

j'ai eu il y quelques temps l'aide d'un colistier*sur une formule
mais je ne me rapelle pas qui et les explications qu'il m'avait donné
je


les ai oubliées

j'ai dans une macro


Sub ControlCouleur()
Dim MyDate, MyWeekDay

CellCol = ActiveCell.Column
Ligne = ActiveCell.Row
MyDate = Cells(3, CellCol)
MyWeekDay = Weekday(MyDate)

If ActiveCell = "AM" Then

If MyWeekDay = 1 Then
ActiveCell = "AMD"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range _
("I3").Interior.ColorIndex ElseIf Not
IsError(Application.Match(CLng(MyDate), Range("feriers"), 0)) Then
ActiveCell = "AMF"
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex Else
'ActiveCell = "A"
Selection.Font.ColorIndex = 1
Selection.Interior.ColorIndex = Sheets("Parametres").Range
("I3").Interior.ColorIndex End If
End If

peut on m'expliquer la ligne suivante

ElseIf Not IsError(Application.Match(CLng(MyDate), Range("feriers"),
0))


Then

car je la macro ne fonctione plus

merci d'avance

Christian