1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Sub aaa()
'verif des colonnes reporting year / month
If Month(Date) = 1 Then
ydate = Year(Date) - 1
mdate = 12
Else
ydate = Year(Date)
mdate = Month(Date) - 1
End If
With ThisWorkbook.Sheets("data")
Dim coly As Integer
coly = .Rows("1:1").Find(What:="reporting_year", LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Column
Dim colm As Integer
colm = .Rows("1:1").Find(What:="reporting_month", LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Column
Dim dl As Long
dl = .Range("A" & Rows.Count).End(xlUp).Row
If Not (WorksheetFunction.CountIf(Range(.Cells(2, coly), Cells(dl, coly)), "<>" & ydate) + WorksheetFunction.CountIf(Range(.Cells(2, colm), Cells(dl, colm)), "<>" & mdate) = 0) Then
MsgBox "Erreur de reporting_year/month sur la sheet data"
Else
If Not (.Cells(2, coly) ydate 2016 And .Cells(2, colm) = mdate ) Then MsgBox "Erreur de reporting_year/month sur la sheet data"
End If
End With
End Sub |
Partager