Thank you for the direction and solution. I did several tests with the adjusted code and it worked like the original. Thank you
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Thank you for the direction and solution. I did several tests with the adjusted code and it worked like the original. Thank you
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Last edited by DocAElstein; 06-11-2023 at 03:29 PM.
Just to follow up...
Admin's solution does not actually work like you intended your original code to... in your original code, you were able to select the cell that contained the date if your active cell was not the correct one, Admin's solution would have you typing the date in under that circumstance. The following method would default the InputBox to the active cell's address, but would allow you to select a different cell if the active cell was not on the correct date to begin with (no typing required)...
Set Cel = Application.InputBox(Prompt, Title, ActiveCell.Address, , , , , 8)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Last edited by DocAElstein; 06-11-2023 at 03:32 PM.
In hind site, Ideally what I would like is when iI click the macro button that activates the code it prompts me for the ending time because the start time was automatically captured as being the active cell. with this code. Mod it confirms the active cell time is correct but I still have to click ok to get the prompt for the ending time
The above will save me a click
I'm think that at the end you get a message box that shows what the start was, what the ending time was and the break time deducted. And of course what the answer the is as a complete check
Do not know if this is possible
Still testing your suggestion will post test results later
Something like this maybe...
Code:Sub GetStartEndTime() Dim StartTime As Date, EndTime As Date, TimeDiff As String StartTime = ActiveCell.Value EndTime = Application.InputBox("Select the cell with the ending time...", Type:=8) TimeDiff = Format(EndTime - StartTime, "h"" hours and ""m"" minutes""") MsgBox "Start time: " & StartTime & vbLf & "End time: " & EndTime & vbLf & "Time difference: " & TimeDiff End Sub
Your mod works very well, I like the hours and minutes to the value, thats really cool. Is it possible to add the break value to this code to say minus 60 minutes the value of the input which is either 30 or 60 ? this way I don't have to mentally deduct it from the times to get the value. Thanks you for the help and direction
How could I hard code 60 which is 60 minutes lunch break or 1-hourdid not work. I'm thinking I can have two buttons one for a 60 minute lunch break or 30 minute lunch break break to be deducted at the end. I hope I explained it better, sorryCode:TimeDiff = Format(EndTime - StartTime, "h"" hours and ""m"" minutes""") - 60
Bookmarks