+ Reply to Thread
Results 1 to 5 of 5

automatic summation in columns

Hybrid View

  1. #1
    Registered User
    Join Date
    05-04-2008
    Posts
    6

    automatic summation in columns

    I attached excel sheet with employee attendance. If you press CALCULATION BUTTON, then macro creates one sheet for each employee. In new created sheets is column with work time. So in the end of this column I would like to see sum of hours. Cell with total time should has blue colour.
    Cells with employee name should have red colour and columns of lunch should have yellow colour.
    Is somebody who knows how to adjust macro?

    Thanks very much
    Attached Files Attached Files

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi standa,

    You could add the following code either as part of the CopyRecord2Tab Sub or as a separate Sub.

    NB You need to format Column G with special format [h]:mm in order to total more than 24 hours.

    Sub Add_Total_And_Colour()
    Dim LastRow As Integer
    LastRow = Range("F65536").End(xlUp).Row
        Range("G3").Value = "Total Hours"
        Range("G:G").NumberFormat = "[h]:mm"
            With Range("G4")
                .FormulaR1C1 = "=SUM(RC[-1]:R[" & LastRow & "2]C[-1])"
                .Interior.ColorIndex = 5
            End With
        Range("B1").Interior.ColorIndex = 3
        Columns("C:D").Interior.ColorIndex = 6
    End Sub
    Hope this helps

    Seamus

  3. #3
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    macro modified

    Hi
    I have modified the codes of seamus (SOS). attached is the file.
    Ravi
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-04-2008
    Posts
    6

    small error

    Thanks, but in first and last employee´s sheet is bad calculation of total work hours.

  5. #5
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    edit macro

    Hi
    The first and last sheet has totals over 24 hours and other sheets do not.you would have got the problem in other sheets too when more rows were added.
    to fix it add as prefix worksheets(a). to the code Range("G:G").NumberFormat = "[h]:mm" save it and run the macro.
    Ravi

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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