En double cliquant dans une cellule je souhaite ouvrir un calendrier

Résolu/Fermé
Guiiggs Messages postés 27 Date d'inscription vendredi 11 janvier 2013 Statut Membre Dernière intervention 24 janvier 2022 - Modifié le 11 févr. 2019 à 15:30
Guiiggs Messages postés 27 Date d'inscription vendredi 11 janvier 2013 Statut Membre Dernière intervention 24 janvier 2022 - 12 févr. 2019 à 11:26
Bonjour,

J'expose mon problème :
1) En faisant plusieurs recherches sur des forums, j'ai pu me construire un fichier excel avec un userform calendrier.
=> Lorsque je double clique sur une cellule, un userform calendrier s'ouvre pour que je puisse choisir une date.

Mon soucis c'est que je souhaite afficher le numéro de semaine sur userform mais je n'arrive pas.

Auriez-vous une idée s'il vous plaît ?

Ci-dessous mon code :

Private Sub ScrollBar1_Change()
  Dim D1 As Date, Deb As Date, Ind As Integer, TabJF() As String
  If ScrollBar1.Value > Label59 Then
    Me.MaDate = DateSerial(Year(CDate(Me.MaDate)), Month(CDate(Me.MaDate)) + 1, "01")
  Else
    Me.MaDate = DateSerial(Year(CDate(Me.MaDate)), Month(CDate(Me.MaDate)) - 1, "01")
  End If
  ' Afficher le bon mois et l'année dans les Comobobox
  Me.CbB_Month.ListIndex = Month(CDate(Me.MaDate)) - 1
  Me.CbB_Year.Value = Year(CDate(Me.MaDate))
  ' Mettre à jour le label
  Label59 = ScrollBar1.Value
  With UsFCalendrier
    D1 = DateSerial(Year(CDate(Me.MaDate)), Month(CDate(Me.MaDate)), "01")
    Deb = (D1 - (D1 - 2) Mod 7)
    .Label52 = "S" & Format(DatePart("ww", Deb + 1, vbMonday, vbFirstFourDays), "00")
    .Label53 = "S" & Format(DatePart("ww", Deb + 8, vbMonday, vbFirstFourDays), "00")
    .Label54 = "S" & Format(DatePart("ww", Deb + 15, vbMonday, vbFirstFourDays), "00")
    .Label55 = "S" & Format(DatePart("ww", Deb + 22, vbMonday, vbFirstFourDays), "00")
    .Label56 = "S" & Format(DatePart("ww", Deb + 29, vbMonday, vbFirstFourDays), "00")
    .Label57 = "S" & Format(DatePart("ww", Deb + 36, vbMonday, vbFirstFourDays), "00")
    For Ind = 1 To 42
      .Controls("Label" & Ind).Caption = Format(Day(Deb), "00")
      If Month(Deb) = Month(D1) Then
        .Controls("Label" & Ind).ForeColor = &H0
      Else
        .Controls("Label" & Ind).ForeColor = &HFFFFFF
      End If
      If ActiveCell = Deb Then
        .Controls("Label" & Ind).BackColor = &H8080FF
      Else
        .Controls("Label" & Ind).BackColor = &H80000004
      End If
      If Deb = Date Then
        .Controls("Label" & Ind).BackColor = &HFFC0C0
      End If
      If Year(Deb) <> Sheets("Fériés").Range("A1") Then Sheets("Fériés").Range("A1") = Year(Deb)
      If Application.CountIf(Sheets("Fériés").Range("A2:A500"), Deb) > 0 Then
        .Controls("Label" & Ind).BackColor = &HC0FFC0
      End If
      Deb = Deb + 1
    Next
  End With
End Sub


Cordialement,
Guiiggs
A voir également:

2 réponses

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 728
11 févr. 2019 à 15:41
Bonjour,

Voir ceci

https://www.excel-exercice.com/numero-de-semaine-a-partir-dune-date/

il est préférable de mettre la date du jeudi!
0
Guiiggs Messages postés 27 Date d'inscription vendredi 11 janvier 2013 Statut Membre Dernière intervention 24 janvier 2022 1
12 févr. 2019 à 11:26
Bonjour cs_Le Pivert,

Merci pour ton aide.

Le sujet est résolu.

Cordialement,
Guiiggs
0