Hi,
I do not have basic knowledge of how macro is done, I have only use record macro or copy macros done by my colleagues.Edit them and make some tests to get the result that I need. This time, I edited the macros that I got and fortunately I got what I wanted on some parts except for putting week number in a specific column, which is column T. The basis of week numbering is column A. When I put date in column A, column T would show week number. Example: If Column A has 8/15/2013 then column T should show 33 as its corresponding week. Below is my existing macro. Appreciate your help on this.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
' Time Tracker Macro
Dim AutoTime
AutoTime = True 'Set to false to remove automatic time stamp
If (AutoTime And ActiveCell = "" And ActiveCell.Column > 14 And ActiveCell.Column < 16 And ActiveCell.Row > 4) Then
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.NumberFormat = "hh:mm"
ElseIf (AutoTime And ActiveCell = "" And ActiveCell.Column = 1 And ActiveCell.Row > 4) Then
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.NumberFormat = "mm/dd/yyyy"
End If
If (AutoTime And ActiveCell = "" And ActiveCell.Column > 15 And ActiveCell.Column < 17 And ActiveCell.Row > 4) Then
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.NumberFormat = "hh:mm"
ElseIf (AutoTime And ActiveCell = "" And ActiveCell.Column = 20 And ActiveCell.Row > 4) Then
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.NumberFormat = "mm/dd/yyyy"
End If
ActiveCell.FormulaR1C1 = WEEKNUM (RC[-20],1)
End Sub
Bookmarks