The formula above assumes that cell A1 contains a valid date for which you want to return the week number. To calculate the correct week number with a user-defined VBA function, you can use the function below: Function WEEKNR(InputDate As Long) As Integer Dim A As Integer, B As Integer, C As Long, D As Integer WEEKNR = 0 If InputDate < 1 Then Exit Function A = Weekday(InputDate, vbSunday) B = Year(InputDate + ((8 - A) Mod 7) - 3) C = DateSerial(B, 1, 1) D = (Weekday(C, vbSunday) + 1) Mod 7 WEEKNR = Int((InputDate - C - 3 + D) / 7) + 1 End Function |
Sub test()
Dim E As Integer
Dim i As Integer
E = [a65536].End(xlUp).Row
For i = 2 To E
Cells(i, 3) = WEEKNR(Cells(i, 1))
Next
End Sub
Dim E As Integer
Dim i As Integer
E = [a65536].End(xlUp).Row
For i = 2 To E
Cells(i, 3) = WEEKNR(Cells(i, 1))
Next
End Sub
출처 : http://www.exceltip.com
'2진법세상' 카테고리의 다른 글
[Freeware] Photoscape - 이미지 편집 프로그램 (0) | 2008.04.09 |
---|---|
[Freeware] Freemind - 브레인스토밍프로그램 (0) | 2008.04.09 |
인터넷 (웹서핑) 을 빠르게 (0) | 2008.02.03 |
[엑셀] 중복 데이타가 있을 때 중복된 값은 하나로 계산하여 세기 2 (0) | 2008.01.29 |
[엑셀] 중복 데이타가 있을 때 중복된 값은 하나로 계산하여 세기 1 (0) | 2008.01.29 |