Variables temps non reconnues

Bonjour,

J'ai du mal avec ce code vba, mes variables de temps ne sont pas reconnues et je ne sais pas pourquoi. Merci d'avance pour une éventuelle aide

Sub Macro4()

Dim startdate As Date

Dim finishdate As Date

startdate = "=""01/""& MONTH(TODAY())-3 & ""/"" & YEAR(TODAY())"

finishdate = "=EOMONTH(""01/""& MONTH(TODAY())-1 & ""/"" & YEAR(TODAY()),0)"

Workbooks("CustoActivity").Worksheets("Pivot2(RFX1)").PivotTables("PivotTable1").PivotFields("Years").ClearAllFilters

Workbooks("CustoActivity").Worksheets("Pivot2(RFX1)").PivotTables("PivotTable1").PivotFields("DealDate").PivotFilters. _

Add Type:=xlDateBetween, Value1:="" & startdate, Value2:="" & finishdate

End Sub

Bonjour,

    startdate = "01/" & Month(Now()) - 3 & "/" & Year(Now())
    finishdate = Application.EoMonth(DateValue("01/" & Month(Now()) - 1 & "/" & Year(Now())), 0)

A+

Je te propose :

Dim startdate As Variant

Dim finishdate As Variant

Sub macro5()

startdate = DateSerial(Year(Now), Month(Now) - 5, 1)

finishdate = DateSerial(Year(Now), Month(Now) - 1, 1)

End Sub

merci a vous 2!!

Par la meme occasion, ou avez vous appris a avoir un tel niveau en vba? A force de pratiquer?

Cordialement

Rechercher des sujets similaires à "variables temps reconnues"