Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Time Calculation w/ Macro
I use a userform to obtain info about clocking in/out at work. This is a
simple user entry userform. Fields are Textbox2 (clock-in) and Textbox3 (clock-out). Time is entered based on 24-hr clock using colon, ie 17:23 (5:23pm). I want to calculate total hours worked. Thus, I need to subtract, then convert to hours. I am able to do this in a spreadsheet using HOURS() and MINUTE(). However, I cannot get it to work in a macro. Here is an example of what I need to happen as I have it in the spreadsheet (but using macro fields). I need to perform same calculation in a macro. User enters: Textbox2 = 8:00 Textbox3 = 17:23 Calculations after user clicks ENTER: ttltime1 = Textbox3 - Textbox3 (should = 9:23) ttltime2 = HOURS(ttltime1) +(MINUTE(ttltime1)/60) (should = 9.38) ttltime2 will then be inserted into the spreadsheet. I also need to know how to DIM all the fields. Thanks in advance, Les |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Time Calculation w/ Macro
ttltime1 = TimeValue(Textbox3) - TimeValue(Textbox2) (should = 9:23)
ttltime2 = HOURS(ttltime1) +(MINUTE(ttltime1)/60) (should = 9.38) "WLMPilot" wrote: I use a userform to obtain info about clocking in/out at work. This is a simple user entry userform. Fields are Textbox2 (clock-in) and Textbox3 (clock-out). Time is entered based on 24-hr clock using colon, ie 17:23 (5:23pm). I want to calculate total hours worked. Thus, I need to subtract, then convert to hours. I am able to do this in a spreadsheet using HOURS() and MINUTE(). However, I cannot get it to work in a macro. Here is an example of what I need to happen as I have it in the spreadsheet (but using macro fields). I need to perform same calculation in a macro. User enters: Textbox2 = 8:00 Textbox3 = 17:23 Calculations after user clicks ENTER: ttltime1 = Textbox3 - Textbox3 (should = 9:23) ttltime2 = HOURS(ttltime1) +(MINUTE(ttltime1)/60) (should = 9.38) ttltime2 will then be inserted into the spreadsheet. I also need to know how to DIM all the fields. Thanks in advance, Les |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop time - start time calculation | Excel Worksheet Functions | |||
Time calculation (Subraction of Idle Time) | Excel Discussion (Misc queries) | |||
Ignoring Time in a Date Time Calculation | Excel Worksheet Functions | |||
Time Calculation - How long a macro takes to run | Excel Programming | |||
Why can't a calculation and macro execute at the same time? | Excel Programming |