Macro para obtener las fechas de un determinado mes y año en Excel

Código

Private Sub Worksheet_Change(ByVal Target As Range)
Dim FI As Date, FF As Date, RD As Range, F As Date, MES_AÑO_paraLISTA As Range, LISTAaPARTIRde As Range
Set MES_AÑO_paraLISTA = Me.Range("")
Set LISTAaPARTIRde = Me.Range("")
If Not Intersect(Target, MES_AÑO_paraLISTA) Is Nothing Then
Me.Range(LISTAaPARTIRde, Me.Cells(Me.Rows.Count, LISTAaPARTIRde.Column)).ClearContents
If Trim(MES_AÑO_paraLISTA.Value) <> "" Then
On Error Resume Next
FI = DateValue(MES_AÑO_paraLISTA.Value & " 1")
On Error GoTo 0
If FI <> 0 Then
FF = DateSerial(Year(FI), Month(FI) + 1, 0)
Set RD = LISTAaPARTIRde
F = FI
Do While F <= FF
RD.Value = F
Set RD = RD.Offset(1, 0)
F = F + 1
Loop
End If
End If
End If
End Sub

Comentarios