PC Review


Reply
Thread Tools Rate Thread

Cell Format Function "NumberFormatLocal" in VBA

 
 
ppt_puppet
Guest
Posts: n/a
 
      4th Jan 2010
Hi,
I have a written a simple macro to convert local time to UTC. The conversion
has no problem but the CellNumberFormat to does not get change to "m/d/yyyy
h:mm". It remains "General". Here is the code of the function. Can someone
please help me in sorting out this issue. This macro would be used both in
Office 2003 and 2007.

Application.Volatile
ActiveCell.NumberFormatLocal = "m/d/yyyy h:mm"
od = dt
Set oShell = CreateObject("WScript.Shell")
atb =
"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
nd = DateAdd("n", offsetMin, od)
LU = nd
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      4th Jan 2010
i changed the format to just the date and ran your code and it changed the
formatting.

did you try ActiveCell.NumberFormat = "m/d/yyyy h:mm"?

not sure why your's isn't changing. are you on the same sheet?
--


Gary Keramidas
Excel 2003


"ppt_puppet" <(E-Mail Removed)> wrote in message
news:C9E6D9EC-F8A0-4B5F-9557-(E-Mail Removed)...
> Hi,
> I have a written a simple macro to convert local time to UTC. The conversion
> has no problem but the CellNumberFormat to does not get change to "m/d/yyyy
> h:mm". It remains "General". Here is the code of the function. Can someone
> please help me in sorting out this issue. This macro would be used both in
> Office 2003 and 2007.
>
> Application.Volatile
> ActiveCell.NumberFormatLocal = "m/d/yyyy h:mm"
> od = dt
> Set oShell = CreateObject("WScript.Shell")
> atb =
> "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"
> offsetMin = oShell.RegRead(atb)
> nd = DateAdd("n", offsetMin, od)
> LU = nd


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format a cell such that "#NAME?" reads/appears "N/A"? Fred Holmes Microsoft Excel Misc 2 18th Jun 2009 06:32 AM
Re: Format a cell such that "#NAME?" reads/appears "N/A"? T. Valko Microsoft Excel Misc 0 18th Jun 2009 03:08 AM
CELL("Format") function and Locale =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV4?= Microsoft Excel Programming 1 13th May 2004 01:10 PM
Why CELL("format",A1) doesn't return something like "#.##"? ...and other rants Raymond Zeitler Microsoft Excel Discussion 2 13th Apr 2004 06:30 PM
How to copy the cell format while using the "IF" function. =?Utf-8?B?SGFyZW4gSmV0aHdh?= Microsoft Excel Worksheet Functions 1 22nd Jan 2004 10:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:10 PM.