Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - clock in buttons problem

Hi, I am creating an automated clocking in/out system.
My spreadsheet runs on a five day week from Monday to Friday.
The spreadsheet has four boxes for each day - book in AM, book out AM,
book in PM and book out PM.

I have two buttons at the bottom of the table - Book in and Book out. I
am having problems making these buttons do what I want them to do.

I have cells containing the formulae to display the current date,
current day and current time.

I want my spreadsheet to be automated, so that when I press the 'Book
in' button, the program will pick up what day it is from my date and
day cells, as well as whether or not it is in the morning or afternoon,
according to my current time cell.

From this information I want it to record the time in the correct "Book
in AM" or "Book in PM" cell of the correct day.

What would be the best way to go about doing this. I considered using
an IF function in the programming, what's the simplest way, has anyone
done something similar before?

Thanks in advance for any feedback :)


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA - clock in buttons problem

All the date information is available in the VBA Now function, so you don't
need to depend on the cells (you would need to force a calculate event to
ensure the time value is updated on the sheet.

Dim sngTime as Single
sngTime = Now - int(now)
if sngTime = .5 then
msgbox "PM"
else
msgbox "AM"
End if

Demo'd from the immediate window:

sngTime = Now - int(now)
? sngTime
0.33223379629635
? format(now,"hh:mm:ss")
07:58:45

it is 7:58 AM

? format(now,"mm/dd/yyyy hh:mm:ss dddd")
02/20/2004 08:00:03 Friday

--
Regards,
Tom Ogilvy


"MikeyMike " wrote in message
...
Hi, I am creating an automated clocking in/out system.
My spreadsheet runs on a five day week from Monday to Friday.
The spreadsheet has four boxes for each day - book in AM, book out AM,
book in PM and book out PM.

I have two buttons at the bottom of the table - Book in and Book out. I
am having problems making these buttons do what I want them to do.

I have cells containing the formulae to display the current date,
current day and current time.

I want my spreadsheet to be automated, so that when I press the 'Book
in' button, the program will pick up what day it is from my date and
day cells, as well as whether or not it is in the morning or afternoon,
according to my current time cell.

From this information I want it to record the time in the correct "Book
in AM" or "Book in PM" cell of the correct day.

What would be the best way to go about doing this. I considered using
an IF function in the programming, what's the simplest way, has anyone
done something similar before?

Thanks in advance for any feedback :)


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Excel VBA - clock in buttons problem

Assuming the "boxes" you have for time entries are cells:

Sub BookInClick()
If Hour(Now) < 12 Then
Range("BookInAM").Value = Now
Else
Range("BookInPM").Value = Now
End If
End Sub

--
Jim Rech
Excel MVP


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
Excel 2003 Custom toolbar problem saving new buttons Karen O Excel Discussion (Misc queries) 6 June 23rd 09 10:42 PM
Incremental time values based upon clock in and clock out times saltnsnails Excel Discussion (Misc queries) 8 January 13th 09 08:11 PM
How do I calculate time in excel (clock in and clock out chad Excel Discussion (Misc queries) 3 January 7th 08 10:09 PM
Change EXCEL Clock to Standard Clock or Military Time YoMarie Excel Worksheet Functions 4 April 29th 07 08:39 PM
Start Clock/Stop Clock abfabrob Excel Discussion (Misc queries) 9 June 28th 05 04:26 PM


All times are GMT +1. The time now is 05:10 AM.

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"