Pon la siguiente macro en los eventos de tu hoja
Private Sub Worksheet_Change(ByVal Target As Range)
Dim d As Date
Dim dia As Long
'
If Not Intersect(Target, Range("D1")) Is Nothing Then
If Target.CountLarge > 1 Then Exit Sub
Application.ScreenUpdating = False
Range("E1:AI3").ClearContents
'
d = CDate("01/" & LCase(Target.Value) & "/" & Year(Date))
dia = Day(DateSerial(Year(d), Month(d) + 1, 1) - 1)
Range("E1").Value = 1
Range("E1").AutoFill Range("E1", Cells(1, 5 + dia - 1)), xlFillSeries
'
With Range("E2", Cells(2, 5 + dia - 1))
.FormulaR1C1 = "=COUNTIF(C1,DATEVALUE(R1C&""/""&R1C4&YEAR(TODAY())))"
.Value = .Value
End With
'
With Range("E3", Cells(3, 5 + dia - 1))
.FormulaR1C1 = "=COUNTIF(C2,DATEVALUE(R1C&""/""&R1C4&YEAR(TODAY())))"
.Value = .Value
End With
'
Application.ScreenUpdating = True
End If
End Sub
Sigue las Instrucciones para poner la macro en los eventos de worksheet
- Abre tu libro de excel
- Para abrir Vba-macros y poder pegar la macro, Presiona Alt + F11
- Del lado izquierdo dice: VBAProject, abajo dale doble click a worksheet(tu hoja)
- En el panel del lado derecho copia la macro