I'm currently working on small macro that can be used to autofill empty cells with certain formula, and I have two questions:
I create UserForm to input the data on the desired worksheet. I have assigned column A and E:AM for the input, and leave cloumn B:D empty.
In the data entry, I have date on column A, and wish to autofill column B,C and D with year, month, and weeknum of the corresponding date.
I'm using this code in modules group but somehow it doesn't work as expected:
Questions:
1. Is there something wrong with the aforementioned code?
2. Is there any way to combine this autofill to the commandbutton_click in my userform?
I create UserForm to input the data on the desired worksheet. I have assigned column A and E:AM for the input, and leave cloumn B:D empty.
In the data entry, I have date on column A, and wish to autofill column B,C and D with year, month, and weeknum of the corresponding date.
I'm using this code in modules group but somehow it doesn't work as expected:
Code:
Sub FillDown()
Dim strFormulas(1 To 3) As Variant
With ThisWorkbook.Sheets("Data")
strFormulas(1) = "=YEAR(A2)"
strFormulas(2) = "=MONTH(A2)"
strFormulas(3) = "=ISOWEEKNUM(A2)"
.Range("B2:D2").Formula = strFormulas
.Range("B2:D" & lRow).FillDown
End With
End Sub
Questions:
1. Is there something wrong with the aforementioned code?
2. Is there any way to combine this autofill to the commandbutton_click in my userform?