OVH Cloud OVH Cloud

No de semaine en VBA

5 réponses
Avatar
René Delcourt
Bonjour,

J'ai essayé d'adapter la formule de Christophe Péjout mais j'ai une erreur 439

Dim datemin
datemin = Now()
Nosemaine =
Application.WorksheetFunction.Int(Application.WorksheetFunction.MOD(Application.WorksheetFunction.Int((datemin - 2) / 7) + 0.6, 52 + 5 / 28)) + 1

Où est l'erreur?
--
René Delcourt

5 réponses

Avatar
Ardus Petus
Peux-tu nous rappeler la formule de c. Péjout?

--
AP

"René Delcourt" a écrit dans le message de news:

Bonjour,

J'ai essayé d'adapter la formule de Christophe Péjout mais j'ai une erreur
439

Dim datemin
datemin = Now()
Nosemaine > Application.WorksheetFunction.Int(Application.WorksheetFunction.MOD(Application.WorksheetFunction.Int((datemin
- 2) / 7) + 0.6, 52 + 5 / 28)) + 1

Où est l'erreur?
--
René Delcourt


Avatar
René Delcourt
OK, j'ai trouvé cette fonction :

Function ISOWeekNum(d1 As Date) As Integer
'Daniel Maher
Dim Jan03 As Long
Jan03 = DateSerial(Year(d1 - Weekday(d1 - 1) + 4), 1, 3)
ISOWeekNum = Int((d1 - Jan03 + Weekday(Jan03) + 5) / 7)
End Function

--
René Delcourt



Bonjour,

J'ai essayé d'adapter la formule de Christophe Péjout mais j'ai une erreur 439

Dim datemin
datemin = Now()
Nosemaine =
Application.WorksheetFunction.Int(Application.WorksheetFunction.MOD(Application.WorksheetFunction.Int((datemin - 2) / 7) + 0.6, 52 + 5 / 28)) + 1

Où est l'erreur?
--
René Delcourt


Avatar
Ardus Petus
A mon avis, ce n'est pas ISO.
Voir : http://www.cpearson.com/Excel/Weeknum.htm


"René Delcourt" a écrit dans le message de news:

OK, j'ai trouvé cette fonction :

Function ISOWeekNum(d1 As Date) As Integer
'Daniel Maher
Dim Jan03 As Long
Jan03 = DateSerial(Year(d1 - Weekday(d1 - 1) + 4), 1, 3)
ISOWeekNum = Int((d1 - Jan03 + Weekday(Jan03) + 5) / 7)
End Function

--
René Delcourt



Bonjour,

J'ai essayé d'adapter la formule de Christophe Péjout mais j'ai une
erreur 439

Dim datemin
datemin = Now()
Nosemaine >> Application.WorksheetFunction.Int(Application.WorksheetFunction.MOD(Application.WorksheetFunction.Int((datemin
- 2) / 7) + 0.6, 52 + 5 / 28)) + 1

Où est l'erreur?
--
René Delcourt




Avatar
René Delcourt
http://www.excelabo.net/xl/calendriers.php#numerosemaine
--
René Delcourt



Peux-tu nous rappeler la formule de c. Péjout?

--
AP

"René Delcourt" a écrit dans le message de news:

Bonjour,

J'ai essayé d'adapter la formule de Christophe Péjout mais j'ai une erreur
439

Dim datemin
datemin = Now()
Nosemaine > > Application.WorksheetFunction.Int(Application.WorksheetFunction.MOD(Application.WorksheetFunction.Int((datemin
- 2) / 7) + 0.6, 52 + 5 / 28)) + 1

Où est l'erreur?
--
René Delcourt







Avatar
AV
|A mon avis, ce n'est pas ISO.

Si, si...
Il y a aussi ça :
Function NUMSEM_ISO(cel As Range) 'AV
If Day(cel) = 2 And Month(cel) = 1 And Year(cel) Mod 400 = 101 Then NUMSEM_ISO =
52: Exit Function
NUMSEM_ISO = IIf(Weekday(cel) = 2 And Month(ladate) = 12 And Day(cel) > 28, 1,
DatePart("ww", cel, 2, 2))
End Function

Et il y a aussi toutes les possibilités à partir des fonctions de feuille et la
fonction Evaluate

AV