Skip i'r prif gynnwys

Sut i gael y parth amser cyfredol a'i arddangos yn y gell yn Excel?

Ydych chi'n gwybod sut i ddarganfod pa barth amser y mae system wedi'i osod iddo yn eich cyfrifiadur? Yma, byddaf yn dangos ffordd hawdd i chi ei gael i lawr yn Excel.

Sicrhewch y parth amser cyfredol a'i arddangos yn y gell gyda swyddogaeth wedi'i diffinio gan y Defnyddiwr


Sicrhewch y parth amser cyfredol a'i arddangos yn y gell gyda swyddogaeth wedi'i diffinio gan y Defnyddiwr

Bydd y swyddogaeth ganlynol a ddiffiniwyd gan y defnyddiwr yn eich helpu i arddangos parth amser cyfredol y system yn uniongyrchol mewn celloedd sydd eu hangen yn Excel. Gwnewch fel a ganlyn.

1. Gwasgwch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwlau. Yna copïwch isod god VBA i mewn i ffenestr y Modiwl.

Cod VBA: Sicrhewch y parth amser cyfredol yn Excel

Function GetTimeZoneAtPresent() As String
'Updated by Extendoffice 20180814
    Dim xObjIs, xObjI
On Error GoTo ER
    Set xObjIs = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * From Win32_TimeZone")
    If xObjIs.Count = 1 Then
        For Each xObjI In xObjIs
            If Len(xObjI.Caption) > 1 Then
                GetTimeZoneAtPresent = xObjI.Caption
                Exit Function
            Else
                GetTimeZoneAtPresent = "Null"
                Exit Function
            End If
        Next
    End If
ER:
    GetTimeZoneAtPresent = "Failed"
End Function

3. Gwasgwch y Alt + Q allweddi i adael y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

4. Dewiswch gell sydd ei hangen arnoch i arddangos y parth amser, teipiwch y fformiwla hon: =GetTimeZoneAtPresent() a gwasgwch y Rhowch allwedd i gael y manylion parth amser. Gweler y screenshot:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (4)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How do I add a label to the output? so it says something like "Current TZ: (UTC-05:00) Eastern Time (US & Canada)" and not just "(UTC-05:00) Eastern Time (US & Canada)"
This comment was minimized by the moderator on the site
Hi ZMGIT,
The following VBA code can do you a favor. Please give it a try.

Function GetTimeZoneAtPresent() As String
'Updated by Extendoffice 20220402
Dim xObjIs, xObjI
On Error GoTo ER
Set xObjIs = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * From Win32_TimeZone")
If xObjIs.Count = 1 Then
For Each xObjI In xObjIs
If Len(xObjI.Caption) > 1 Then
GetTimeZoneAtPresent = "Current TZ:" & xObjI.Caption
Exit Function
Else
GetTimeZoneAtPresent = "Null"
Exit Function
End If
Next
End If
ER:
GetTimeZoneAtPresent = "Failed"
End Function
This comment was minimized by the moderator on the site
This macro is not taking daylight savings into account. I am in Continental Europe and the current time here is UTC+2, namely one hour earlier than London plus 1 hour for summer time. The function says "(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague" which would be correct during winter but not during summer
This comment was minimized by the moderator on the site
This worked brilliantly. I'm writing an IF statement off of this though. Do you have a list of the values that this formula could potentially display?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations