XL pour MAC Recherche date

tdenis

XLDnaute Nouveau
Bonjour Le forum,
j'ai un petit soucis sur la recherche d'une date, une fois trouvée la cellule trouvée en rapport avec la date, action je sélectionne la cellule +1 (en rapport avec la ligne créee (7))
pouvez vous m'aider sur le petit code ci-dessous ( partie soulignée) le reste fonctionne ;)
je vous remercie par avance.
thierry
VB:
Private Sub Dateintervention()
Dim TheDate As Long, Index As Variant
 Dim s As Variant
Dim d As Date
Dim Calendrier As Date
Dim c As Variant
Dim cellule As Range
Dim FeuillePrecedente As String
Dim Dateintervention As Variant
Dim NbHeures As Variant
Dim NbJours As Variant
FeuillePrecedente = ActiveSheet.Name
d = Dateintervention
lrow = Selection.Row()
TheDate = Dateintervention

Dateintervention = InputBox("Quelle est la date d'intervention ?", "Date d'intervention", "")

Sheets("Recap Dev.Fac").Range("B2").Value = Dateintervention
Sheets("Recap Dev.Fac").Range("B2").NumberFormat = "dd/mm/yy"
Range("B16").Value = Dateintervention
Range("B16").NumberFormat = "dd/mm/yy"

Sheets("Planning ").Select
    
        Rows("7").Select
               lrow = Selection.Row()
        Rows(lrow).Select
        Selection.Copy
        Rows(lrow + 1).Select
                  
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Application.EnableEvents = False
    Range(Cells(7, 1), Cells(7, 7)).Interior.ColorIndex = 34
    Range("A7").Value = Sheets(FeuillePrecedente).Range("B2").Value
    Range("C7").Value = Sheets(FeuillePrecedente).Range("F4").Value
    Range("D7").Value = Sheets(FeuillePrecedente).Range("H4").Value
    Range("E7").Value = Sheets(FeuillePrecedente).Range("F5").Value
    

    
   [U] For Each s In ActiveWorkbook.Sheets
        With Sheets("Planning ").Range(Cells(3, 8), Cells(3, 371))
            Set c = .Find(What:=Format(d, "dd/ mmmm /yyyy"), LookIn:=xlValues)
            If Not c Is Nothing Then
                premier = c.Address
                Do
                    cellule.Interior.ColorIndex = 4
                    Sheets("Planning ").Select
                    Set c = .FindNext(c)
                Loop While Not c Is Nothing And c.Address <> premier
            End If
        End With
    Next s[/U]
    NbJours = InputBox("Quel est le nombre de jours prévu ?", "Nombre de jours", "")
    Range("G7").Value = NbJours
    With Selection.Borders(xlEdgeLeft)
                    .LineStyle = xlContinuous
                    .ColorIndex = xlAutomatic
                    .TintAndShade = 0
                    .Weight = xlMedium
                End With
                With Selection.Borders(xlEdgeTop)
                    .LineStyle = xlContinuous
                    .ColorIndex = 0
                    .TintAndShade = 0
                    .Weight = xlMedium
                End With
                
                Selection.Borders(xlEdgeRight).LineStyle = xlNone
                Selection.Borders(xlInsideVertical).LineStyle = xlNone
                Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Application.EnableEvents = False
End Sub
 

tdenis

XLDnaute Nouveau
Bonjour tbft Nairolf,
merci pour vos réponses et interrogations.
j'ai enlevé le s et la variable cellule..
voici le code, je n'ai pas d'erreur mais ma cellule recherchée donc la date d'intervention ne se sélectionne pas et ne se colore pas ..
je suis perdu
merci pour vos orientations ou solutions;
thierry
VB:
Private Sub Dateintervention()
Dim TheDate As Long, Index As Variant
 
Dim d As Date
Dim Calendrier As Date
Dim c As Variant
Dim cellule As String
Dim FeuillePrecedente As String
Dim Dateintervention As Variant
Dim NbHeures As Variant
Dim NbJours As Variant
FeuillePrecedente = ActiveSheet.Name
d = Dateintervention
lrow = Selection.Row()
TheDate = Dateintervention

Dateintervention = InputBox("Quelle est la date d'intervention ?", "Date d'intervention", "")

Sheets("Recap Dev.Fac").Range("B2").Value = Dateintervention
Sheets("Recap Dev.Fac").Range("B2").NumberFormat = "dd/mm/yy"
Range("B16").Value = Dateintervention
Range("B16").NumberFormat = "dd/mm/yy"

Sheets("Planning ").Select
    
        Rows("7").Select
               lrow = Selection.Row()
        Rows(lrow).Select
        Selection.Copy
        Rows(lrow + 1).Select
                  
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Application.EnableEvents = False
    Range(Cells(7, 1), Cells(7, 7)).Interior.ColorIndex = 34
    Range("A7").Value = Sheets(FeuillePrecedente).Range("B2").Value
    Range("C7").Value = Sheets(FeuillePrecedente).Range("F4").Value
    Range("D7").Value = Sheets(FeuillePrecedente).Range("H4").Value
    Range("E7").Value = Sheets(FeuillePrecedente).Range("F5").Value
    

    
    For Each c In ActiveWorkbook.Sheets
        With Sheets("Planning ").Range(Cells(6, 8), Cells(6, 371))
            Set c = .Find(What:=Format(Dateintervention, "dd/ mmmm /yyyy"), LookIn:=xlValues)
            If Not c Is Nothing Then
                premier = c.Address
                Do
                    Range(7, 12).Select
                    Selection.Interior.ColorIndex = 4
                    Sheets("Planning ").Select
                    Set c = .FindNext(c)
                Loop While Not c Is Nothing And c.Address <> premier
            End If
        End With
    Next c
    NbJours = InputBox("Quel est le nombre de jours prévu ?", "Nombre de jours", "")
    Range("G7").Value = NbJours
    With Selection.Borders(xlEdgeLeft)
                    .LineStyle = xlContinuous
                    .ColorIndex = xlAutomatic
                    .TintAndShade = 0
                    .Weight = xlMedium
                End With
                With Selection.Borders(xlEdgeTop)
                    .LineStyle = xlContinuous
                    .ColorIndex = 0
                    .TintAndShade = 0
                    .Weight = xlMedium
                End With
                
                Selection.Borders(xlEdgeRight).LineStyle = xlNone
                Selection.Borders(xlInsideVertical).LineStyle = xlNone
                Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Application.EnableEvents = False
End Sub
 

Discussions similaires

Réponses
1
Affichages
119

Statistiques des forums

Discussions
311 725
Messages
2 081 940
Membres
101 845
dernier inscrit
annesof