Excel user defined function working on Windows, but does not work on a Mac

drWireMORE

New Member
Joined
Jul 30, 2015
Messages
6
From another thread, a MVP offered a solution which gives you UTC time in a cell. A user defined function similar but different than now()

It works flawlessly on my windows workstation, but presents a value error on my Apple Mac Workbook. Microsoft learn has not revealed why or how to fix it. Do understand behind the covers, the numbers/numeric values may be different, but this is an approved call. Pretty vanilla. (Function is the body of work from D, MVP, Canada)

In lieu of a UTC date/time value, on a Mac it returns #VALUE!

Excel/M365. Excel/Microsoft 365 Version 2312 enterprise.

Function GimmeUTC()
' Returns current date/time at UTC-GMT as an Excel serial date value
Dim dt As Object
Set dt = CreateObject("WbemScripting.SWbemDateTime")
dt.SetVarDate Now
GimmeUTC = dt.GetVarDate(False)
End Function

drW
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
The problem comes from the 'WbemScripting' being part of the Windows framework, something that Mac OSX doesnt have.

Here is a previous post that should answer your question, but there might not be a straight forward solution to your problem. I have ran into several issues where Mac simply can not preform simple solutions inside of Windows, and viceaersa.
 
Upvote 0
The problem comes from the 'WbemScripting' being part of the Windows framework, something that Mac OSX doesnt have.

Here is a previous post that should answer your question, but there might not be a straight forward solution to your problem. I have ran into several issues where Mac simply can not preform simple solutions inside of Windows, and viceaersa.

Thank you - that explains it in part, a windows framework vs Mac OSX are different. I tried the solution including adding a PtrSafe preface and it was no-joy.

It does present me this option: check the OS
If Windows to use the UTC() or GimmeUTC() UDF
If MAC to use now() - a hard coded 5/24 or 6/24 as an approximation of UTC in the midwest, ignoring spring fwd, fall back. <<< but not very elegant.

It did help, just might be a dated approach, or I haven't tried enough combinations to make it work. TY
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top