Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell Format Function "NumberFormatLocal" in VBA

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\Contr ol\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
nd = DateAdd("n", offsetMin, od)
LU = nd
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Cell Format Function "NumberFormatLocal" in VBA

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" wrote in message
...
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\Contr ol\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
nd = DateAdd("n", offsetMin, od)
LU = nd


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
Format a cell such that "#NAME?" reads/appears "N/A"? Fred Holmes Excel Discussion (Misc queries) 3 June 18th 09 06:32 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Format cell to display "Y" or "N"when entering a 1 or zero Brad Excel Discussion (Misc queries) 7 February 8th 07 06:50 PM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM
CELL("Format") function and Locale Kevin McCartnex Excel Programming 1 May 13th 04 01:10 PM


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