Results 1 to 2 of 2

macro for weeknum

Threaded View

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    Taguig, Philippines
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    1

    Post macro for weeknum

    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
    Last edited by aesanchez; 08-16-2013 at 01:09 AM. Reason: changed on the title and add code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Combine codes into one macro
    By Russ Fuquay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-24-2013, 10:48 AM
  2. Combining vba codes makes the previous codes broken !
    By MDPLUS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2013, 10:00 AM
  3. Macro to lookup many codes
    By hunsnowboarder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2008, 01:08 PM
  4. Replies: 6
    Last Post: 11-28-2006, 01:08 PM
  5. Macro (Codes)
    By Bonbon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2006, 12:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1