Apoyo para que condición no aplique en datos de fecha actual
Publicado por Camila (1 intervención) el 07/02/2020 18:26:23
Buenas tardes,
Tengo una tabla dinamica por fecha que se divide en "D" y "L". Realicé un código con una condición que es pintar la tabla dinamica según el criterio (se muestra en el código), en lo que necesito ayuda es en que no se aplique esa condicion para el día que sacan el reporte en la columna "L" (por ejemplo, si se saca hoy el reporte, toda la columna "L" del día 07 se quede pintada de verde pero mañana que ya pueda validarse esa condicion y que se aplique para el día 08 y asi sucesivamente)
Adjunto imagen de la tabla dinamica y la tabla donde obtengo los datos
Ayudemne por favor
no se como agregar esa condicion
Este es mi codigo


Tengo una tabla dinamica por fecha que se divide en "D" y "L". Realicé un código con una condición que es pintar la tabla dinamica según el criterio (se muestra en el código), en lo que necesito ayuda es en que no se aplique esa condicion para el día que sacan el reporte en la columna "L" (por ejemplo, si se saca hoy el reporte, toda la columna "L" del día 07 se quede pintada de verde pero mañana que ya pueda validarse esa condicion y que se aplique para el día 08 y asi sucesivamente)
Adjunto imagen de la tabla dinamica y la tabla donde obtengo los datos
Ayudemne por favor

Este es mi codigo
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Sub Condiciones()
Dim ANALISIS As Worksheet
Dim Tabla As Worksheet
Dim PT As PivotTable
Dim rn1 As Range
Dim rn2 As Range
Dim rn3 As Range
Dim rn4 As Range
Dim rn As Range
Dim DiaUlt As String
Dim fecha As String
Dim aux As String
Dim inicio As Integer
Dim rne1 As Range
Dim rne2 As Range
Dim rne3 As Range
Dim rne4 As Range
Dim rne As Range
Dim DiaUlti As String
Dim hoy As String
Dim fech As String
Dim auxi As String
Dim comienzo As Integer
On Error Resume Next
aux = Worksheets("TABLA").Range("E1").End(xlDown).Row
fecha = Worksheets("TABLA").Cells(aux, 5).Value
DiaUlt = Day(fecha)
inicio = 1
Set PT = Worksheets("ANALISIS").PivotTables("ANALISIS")
Set rn1 = PT.PivotFields("Count of Type").DataRange
Set rn2 = PT.PivotFields("Type").PivotItems("D").DataRange
Set rn3 = PT.PivotFields("SrvName").DataRange.EntireRow
For i = inicio To DiaUlt
Set rn4 = PT.PivotFields("Dia").PivotItems(inicio).DataRange
For Each rn In Intersect(rn1, rn2, rn3, rn4)
If rn.Value = "N/A" Then
rn.Interior.Color = RGB(128, 128, 128)
Else
rn.Interior.Color = RGB(112, 173, 71)
End If
Next
inicio = inicio + 1
Next i
auxi = Worksheets("TABLA").Range("E1").End(xlDown).Row
fech = Worksheets("TABLA").Cells(auxi, 5).Value
DiaUlti = Day(fech)
hoy = "=TODAY()"
comienzo = 1
Set PT = Worksheets("ANALISIS").PivotTables("ANALISIS")
Set rne1 = PT.PivotFields("Count of Type").DataRange
Set rne2 = PT.PivotFields("Type").PivotItems("L").DataRange
Set rne3 = PT.PivotFields("SrvName").DataRange.EntireRow
For c = comienzo To DiaUlti
Set rne4 = PT.PivotFields("Dia").PivotItems(comienzo).DataRange
For Each rne In Intersect(rne1, rne2, rne3, rne4)
If rne.Value <= 23 Then
rne.Interior.Color = RGB(192, 0, 0)
ElseIf rne.Value = "N/A" Then
rne.Interior.Color = RGB(128, 128, 128)
Else
rne.Interior.Color = RGB(112, 173, 71)
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End If
Next
comienzo = comienzo + 1
Next c
End Sub


Valora esta pregunta


0