Written by Allen Wyatt (last updated September 4, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
When Farol uses the shortcut Ctrl+Shift+; Excel enters the local time in the cell. He wonders if there is any way to have it, instead, enter GMT (+7 or +8 hours) into the cell.
There is no way to configure Excel to do this, but it is a very easy task to create a macro that will enter the adjusted time. If you know that your local time is 8 hours behind GMT, then you can use a macro such as the following:
Sub EnterGMT() ActiveCell = Time + (8 / 24) End Sub
You can then assign the macro to a shortcut key and use it to enter the time in any cell. If your local time is actually 7 hours behind GMT, then simply change the 8 to a 7 in the formula.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13084) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Work with times in a worksheet and you will eventually want to start working with elapsed times. Here's an explanation of ...
Discover MoreExcel allows you to store times in your worksheets. If you have your times stored in one column and an AM/PM indicator in ...
Discover MoreDealing with times in Excel is fairly straightforward, except when it comes to midnight. Some people prefer that midnight ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-09-04 16:03:19
Mike
A more general solution, which would appear to work in any time zone, at any time of the year, can be found here.
https://stackoverflow.com/questions/1600875/how-to-get-the-current-datetime-in-utc-from-an-excel-vba-macro/23968601
The code is written as a UDF but to run it as a sub, the code in the tip could then be:
Sub EnterGMT()
ActiveCell = Format(UtcTime(Time), "hh:mm")
End Sub
2021-09-04 11:04:33
Tomek
You have to remember to change this macro when there is a change from summer to standard time. Is there a function that can tell whether the current time is standard or daylight savings time?
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments