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
|
Option Explicit
Option Base 1
Dim Year_Date As Integer
Dim Month_Date As Byte
Dim Tab_Temp() As Variant
Dim Tab_Recup() As Variant
Public Sub FillInEmpty()
Dim lastRow As Long
Dim DerCol As Byte
Dim i As Long
Dim ws As Worksheet
Dim Rep As Integer
Erase Tab_Recup
Set ws = Sheets("Page1_1")
Rep = MsgBox("Are you willing to copy all dates into this column?", vbYesNo + vbQuestion, "mDF XLpages.com")
If Rep = vbYes Then
With ws
lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
DerCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Tab_Temp = .Range(.Cells(2, 1), .Cells(lastRow, DerCol)).Value
ReDim Tab_Recup(1 To UBound(Tab_Temp, 1), 1)
For i = 1 To UBound(Tab_Temp, 1)
If Tab_Temp(i, 35) = "" Then
Year_Date = Mid(Tab_Temp(i, 29), 1, 4)
Month_Date = Mid(Tab_Temp(i, 29), 5, 2)
Tab_Recup(i, 1) = DateSerial(Year_Date, Month_Date, 1)
Else
Tab_Recup(i, 1) = Tab_Temp(i, 35)
End If
Next i
With .Cells(2, 35).Resize(UBound(Tab_Recup, 1))
.NumberFormat = "mm/yyyy"
.Value = Tab_Recup
End With
End With
End If
End Sub |
Partager