Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro on Mac OSX

Someone on another group graciously supplied this macro to me this
morning. It deposits the date and time into a cell and flashes up a message
box warning the user if it is after time X (in this case, 12 noon). My problem
is that, while the macro runs and deposits the time into the active cell just
great, the message box does not appear. (At the time I ran the tests, it was
already past noon.)

Since I'm running this in Excel X for mac, I thought perhaps someone here
might know of a mac issue that's keepiing this from working all the way.
Thank you!

Sub NewDateAndTime()

Dim mPrompt As String
Dim mBoxStyle As Long
Dim mTitle As String
Dim mMsg As Variant

mPrompt = "It's past 12:00 PM!"
mBoxStyle = 16 ' vbCritical
mTitle = "Warning!"

With ActiveCell

.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"

If Now Mod 1 12 / 24 Then ' 12/24 = 12:00 PM
mMsg = MsgBox(mPrompt, mBoxStyle, mTitle)
.ClearContents
End If

End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Macro on Mac OSX

Hi Michael,

Instead of
If Now Mod 1 12 / 24 Then ' 12/24 = 12:00 PM
use:
If Hour(Now) = 12 Then ' past noon

Regards,

Daniel M.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro on Mac OSX

Thanks for the response. Actually, Excel crashed on me a while ago so I
can't try your suggestion now. I'll try tomorrow and let you know. Thanks!
-----Original Message-----
Hi Michael,

Instead of
If Now Mod 1 12 / 24 Then ' 12/24 = 12:00 PM
use:
If Hour(Now) = 12 Then ' past noon

Regards,

Daniel M.


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro on Mac OSX

VBA's Mod() function is different from XL's MOD() function. From XL/VBA
Help:

The modulus, or remainder, operator divides number1 by number2 (rounding
floating-point numbers to integers) and returns only the remainder as result


Since floating point numbers are rounded to integers, X Mod 1 will
always return 0.

One way:


If Time #12:00:00 PM# Then



In article ,
"Michael Link" wrote:

Someone on another group graciously supplied this macro to me this
morning. It deposits the date and time into a cell and flashes up a message
box warning the user if it is after time X (in this case, 12 noon). My
problem
is that, while the macro runs and deposits the time into the active cell just
great, the message box does not appear. (At the time I ran the tests, it was
already past noon.)

Since I'm running this in Excel X for mac, I thought perhaps someone here
might know of a mac issue that's keepiing this from working all the way.
Thank you!

Sub NewDateAndTime()

Dim mPrompt As String
Dim mBoxStyle As Long
Dim mTitle As String
Dim mMsg As Variant

mPrompt = "It's past 12:00 PM!"
mBoxStyle = 16 ' vbCritical
mTitle = "Warning!"

With ActiveCell

.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"

If Now Mod 1 12 / 24 Then ' 12/24 = 12:00 PM
mMsg = MsgBox(mPrompt, mBoxStyle, mTitle)
.ClearContents
End If

End With

End Sub

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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 04:53 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"