+ Reply to Thread
Results 1 to 9 of 9

trying to create a button that calculates time spent on a task

  1. #1
    Registered User
    Join Date
    04-04-2019
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    4

    trying to create a button that calculates time spent on a task

    Hi,

    A quick introduction:

    I am a high school teacher with no background in excel except my fascination for it.

    I am trying to create a spreadsheet with analytics for my marking progress to help me churn through piles of exams and assignments.

    So far I have created a button that removes 1 from the column of 'left to grade' and adds 1 to the column for 'completed'. I added a graph and it helps keeps me motivated during the hours and hours of marking.

    I am trying to create a button that adds the current time to a cell and then moves on to add the current time to the next cell (.e.g click the button and the current times gets input in A2. Click button again and the current time gets added to B2 (column c will do a2-a1 to work out time spent on that paper). Click the button again and the current time gets added to A3, then B3, A4, B4 and so on).

    I've tried figuring it out myself from basic tutorials and it seems there's a few possible ways it can be done (Using if then, elseif, ISBLANK and >0 (supposedly very easily), but I keep getting lots of errors.

    Please don't laugh at me too hard, I have no background in coding and I assume the solution will probably be much more complex than I was anticipating.


    Range("A2").Select
    If ("A2") ISBLANK
    ActiveCell.FormulaR1C1 = "=Now()"
    ElseIf Selection.Offset(1, 0) Then
    ActiveCell.FormulaR1C1 = "=Now()"
    ElseIf Selection.Column < 2 Then
    Selection.Offset(-1, -1).Select
    ActiveCell.FormulaR1C1 = "=Now()"
    ElseIf Selection.Offset(1, 0) Then
    ActiveCell.FormulaR1C1 = "=Now()"
    ElseIf Selection.Column < 2 Then
    Selection.Offset(-1, -1).Select

    End

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: trying to create a button that calculates time spent on a task

    Hi CalamL and welcome to the forum.

    I am sure over time you will get much information & assistance from the many volunteers who contribute tot he discussion threads.

    There are of course "forum rules" to follow and I am confident one of the moderators will update you these.

    One of the key things to always remember is that attaching an example spreadsheet will pretty much guarantee that you get a quicker response and possible solution. Most of us are "time poor" (something a teacher would understand I suspect ) and don't have the time to generate a spreadsheet to test suggestions on before we reply. One of the good things but also equally a bad thing is that there are many ways to deal with a question in excel, some better that others but provided you get the correct outcome almost any solution will do.

    the example doesn't need to be big, it just needs to show the inputs you will be working with and the expected outcome of the process.

    Look forward to seeing your current progress and, hopefully, being able to assist.

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: trying to create a button that calculates time spent on a task

    .
    One suggestion. The format can be changed around to suit your needs.

    Please Login or Register  to view this content.
    Double-click in the appropriate cell Row 2 and Row 3 for begin / end times. Total time auto displayed from formula in Row 4.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-04-2019
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: trying to create a button that calculates time spent on a task

    Thanks for the info jmac. I mistakenly thought that the experts here would just bang it out from their keyboard.

    I look forward to learning a lot. I enjoy tooling around occasionally but am very basic. I once made a calculator for levelling up in MW2 that had a few bits of data and calculations in it. I thought it was great but it was very basic haha.


    Thanks for the response Logit!

    I'll upload a copy of my spreadsheet now so you can get a better idea of what it is and what I need.

    I want my single button at the top to continue counting up and down for me, as well as adding the current time into the "time started" and "time stopped" cells.

    I also just realised that the time started can be taken from the time stopped of the previous job and considering that I only want to have to click the button once when I finish marking an assignment, I cant do a click for both start and stop so will need to workout a trick for that :/
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: trying to create a button that calculates time spent on a task

    Quote Originally Posted by CalamL View Post

    I also just realised that the time started can be taken from the time stopped of the previous job :/
    What happened to a good old fashioned coffee break between papers???

  6. #6
    Registered User
    Join Date
    04-04-2019
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: trying to create a button that calculates time spent on a task

    Haha. The main issue is that if I press it twice it will add 2 to my done pile. I wish it was that easy to knock them over

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: trying to create a button that calculates time spent on a task

    .
    Paste this into your macro. Make certain the first time you run the macro, you have selected B7 as your active cell.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-04-2019
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: trying to create a button that calculates time spent on a task

    Thank you! It solved my problem and I will learn from it.

    You're a legend. Hope you feel good

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: trying to create a button that calculates time spent on a task

    You are welcome.

+ 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] Stop Time Button to capture Time Spent
    By 323100N in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2017, 09:25 AM
  2. Create New Task Button, Create New Row in Existing Task Button
    By shelton_4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2015, 06:32 AM
  3. need function to calculate time spent on the given task
    By Giri.hb in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2015, 04:44 AM
  4. [SOLVED] inputting a number representing "Time" spent on a "Task" under drop menu's
    By cubbymonkey in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-09-2014, 04:03 PM
  5. Replies: 6
    Last Post: 02-28-2012, 10:50 AM
  6. Replies: 3
    Last Post: 07-01-2011, 10:23 AM
  7. Time Tracker - I need a macro that calculates the time spent on an activity
    By amark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2011, 09:55 AM

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