Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop time - start time calculation squack21 Excel Worksheet Functions 5 December 10th 07 03:20 PM
Time calculation (Subraction of Idle Time) Ajay Excel Discussion (Misc queries) 6 March 4th 07 11:54 AM
Ignoring Time in a Date Time Calculation nmp Excel Worksheet Functions 3 November 23rd 05 08:32 PM
Time Calculation - How long a macro takes to run cdb Excel Programming 7 March 31st 05 08:51 AM
Why can't a calculation and macro execute at the same time? Katy[_3_] Excel Programming 9 June 15th 04 03:17 PM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"