+ Reply to Thread
Results 1 to 18 of 18

#Sum time in application.index#

  1. #1
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    #Sum time in application.index#

    I have data in C2:F10
    Data in format time "hh:mm"
    I want sum time using application.index
    But result not correct
    Please Login or Register  to view this content.
    Last edited by daboho; 02-10-2018 at 10:01 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Is it vital that you use a macro for this? Won't a standard excel function do it sum the times - even if you need to add the function with a macro.
    Why not upload the workbook and manually add the results you expect so that we can better understand.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: #Sum time in application.index#

    Because i have data filter criteria by > mindate and < maxdate ,and filter by name unique
    In my coding has sucses to filter by criteria
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Nevertheless please upload the workbook as requested.
    You may be correct but I am by no means certain and will reserve judgment unti I can see the workbook.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: #Sum time in application.index#

    @daboho- This procedure uses Excel's SUBTOTAL function - which is designed to work with filtering - to sum visible cells:
    Please Login or Register  to view this content.
    In the above code, the formula acts on the first 4 columns in CurrentRegion. Make sure they're the correct columns.

    PS- In your original code, this line won't work:
    Please Login or Register  to view this content.
    Specialcells returns a multi-area range. If you try to assign its values to a variant, only the first area's values will be passed. However, you could store the multi-area range in an object variable:
    Please Login or Register  to view this content.
    Last edited by leelnich; 02-10-2018 at 05:05 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  6. #6
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: #Sum time in application.index#

    this is file O1 = minDate,Q1 = maxdate and filter by nama in col N
    leelnich is posibel to calculate time in value or in array vba ??
    Richard Buttrey is posibel using formula ??
    Attached Files Attached Files
    Last edited by daboho; 02-10-2018 at 05:07 PM.

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: #Sum time in application.index#

    Here's TWO ways to do it in code. The simplest involves placing a straightforward SUMIFS formula on the sheet, then replacing it with VALUE. Of course, you could just enter the formula straight into the cells. I used full-column references here because the formula is temporary, but beware of using them in permanent formulas, as they can really slow down sheet calculation.
    Please Login or Register  to view this content.
    The second is more involved, using the Worksheet.Evaluate method to multiply Conditional Arrays, somewhat like a SUMPRODUCT formula. This is much more similar to your original approach with loops and such:
    Please Login or Register  to view this content.
    NOTE: Neither method addresses filtered rows, as both involve defining criteria by a different method. If this is an issue, the SUBTOTAL worksheet function mentioned earlier can be configured to ignore filtered rows, and might be worthy of investigation. Regards - Lee
    Last edited by leelnich; 02-11-2018 at 05:57 AM.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Would you describe exactly what you are wanting to do and why for instance O3, O5 & O6 reference exactly the same cells.

    It seems to me that you could probably use a Pivot Table and avoid formulae or VBA altogether. Although I admit at the moment I don't understand why you apparently want to exclude row 2 when it's within your criteria range.

  9. #9
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: #Sum time in application.index#

    second makro result is different with first coding
    maybe time can not to sum in string or array or maybe only can store after calculation
    matrik = hour(r.value)+minute(r.value)
    but thank for you attention

  10. #10
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: #Sum time in application.index#

    not similar using pivot table and can not using pivot table

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Do you mean you don't know how to use a Pivot Table?
    Tell us what you're trying to do and answer the implied question about why you are exclusing row 2.

    Do that and mybe we can show you how to use a Pivot Table.

  12. #12
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: #Sum time in application.index#

    Yes i dont know abaut pivot table

  13. #13
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: #Sum time in application.index#

    Quote Originally Posted by daboho View Post
    second makro result is different with first coding...
    matrik = hour(r.value)+minute(r.value)...
    What is "r.value"?

    My output from both (Number Format = "[h]:mm"):

    Row\Col
    N
    O
    P
    Q
    R
    S
    T
    1
    Tgl awal
    2/3/2018
    tgl akhir
    2/13/2018
    2
    nama
    scan masuk
    scan pulang
    terlambat
    plg.cepat
    Absen
    Lembur
    3
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    4
    bg
    20:48
    20:48
    9:54
    20:48
    20:48
    20:48
    5
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    6
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    7
    b
    46:42
    46:42
    46:42
    46:42
    46:42
    46:42
    8
    k
    14:54
    14:54
    14:54
    14:54
    14:54
    14:54
    9
    c
    16:54
    16:54
    16:54
    16:54
    16:54
    16:54
    10
    11
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    12
    bg
    20:48
    20:48
    9:54
    20:48
    20:48
    20:48
    13
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    14
    s
    41:36
    32:42
    32:42
    41:36
    41:36
    41:36
    15
    b
    46:42
    46:42
    46:42
    46:42
    46:42
    46:42
    16
    k
    14:54
    14:54
    14:54
    14:54
    14:54
    14:54
    17
    c
    16:54
    16:54
    16:54
    16:54
    16:54
    16:54
    Last edited by leelnich; 02-11-2018 at 02:40 PM.

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    ....why do you exclude row 2 in your example?

  15. #15
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: #Sum time in application.index#

    Ignore This... I thought Richard's post#14 addressed my output in post#13. Upon reflection, I realized his question was directed to OP.
    Quote Originally Posted by Richard Buttrey View Post
    ....why do you exclude row 2 in your example?
    Richard, the formula version uses full-column references:
    Please Login or Register  to view this content.
    ...so I'm pretty sure row 2 is examined. I think a better question is:

    "Why are there duplicate names in the list on the right?"
    Last edited by leelnich; 02-12-2018 at 01:58 AM.

  16. #16
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Quote Originally Posted by leelnich View Post
    so I'm pretty sure row 2 is examined.
    I don't believe so. The requirement seems to be to analyse data between 3/2/2018 & 13/2/2018 inclusive - else why specify those as criteria?
    So why does the O3 forrmula for instance not mention E2?

  17. #17
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #Sum time in application.index#

    Does the attached with a Pivot Table give you the sort of results you want.

    I've only included an analysis of column E for simplicity.
    Attached Files Attached Files

  18. #18
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: #Sum time in application.index#

    Quote Originally Posted by leelnich View Post
    Richard, the formula version uses full-column references:
    Please Login or Register  to view this content.
    ...so I'm pretty sure row 2 is examined...
    Quote Originally Posted by Richard Buttrey View Post
    I don't believe so...why does the O3 formula for instance not mention E2?
    Sorry, Richard, we were talking about 2 different formulas. I was referring to the one quoted. You were discussing the OP's ORIGINAL formula:
    Please Login or Register  to view this content.
    My mistake.
    Last edited by leelnich; 02-12-2018 at 02:09 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Explain me is different as value and application.index
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-04-2018, 08:54 AM
  2. application.index with speciallcells(1,2) and add columns is problem
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2017, 03:46 AM
  3. Application.Index & Match nested within a loop
    By Homeslice01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2017, 02:34 AM
  4. Replies: 3
    Last Post: 04-04-2017, 04:52 PM
  5. List Index based Inventory Application Help
    By Kurokojin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-11-2014, 11:27 PM
  6. [SOLVED] Is it possible to use Application.Index to write 2 adjoining columns in one go?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-13-2013, 07:11 AM
  7. Move/Index Application
    By Grandpa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2012, 02:13 PM

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