Skip i'r prif gynnwys

Sut i popio calendr wrth glicio cell benodol yn Excel?

Gan dybio bod ystod colofn mewn taflen waith mae angen i chi nodi a newid dyddiadau y tu mewn yn aml, ond mae'n ddiflas nodi neu newid dyddiad â llaw bob tro. Sut i nodi dyddiadau yn gyflym heb deipio â llaw i'r ystod colofnau? Mae'r erthygl hon yn sôn am popio calendr wrth glicio ar gelloedd mewn ystod benodol, yna mewnosod dyddiad yn y gell a ddewiswyd yn awtomatig ar ôl dewis dyddiad yn y calendr.


Codwch galendr wrth glicio cell benodol gyda chod VBA

Datryswch y broblem hon fel a ganlyn gam wrth gam.

Nodyn: Dim ond ar 32-bit Microsoft Excel y gall y dull hwn weithio.

Cam 1: Creu Fformat Defnyddiwr gyda chalendr

Os gwelwch yn dda creu UserForm sy'n cynnwys y calendr y byddwch chi'n ei popio trwy glicio ar gell.

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

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Ffurflen Defnyddiwr.

3. Yna a Ffurflen Defnyddiwr a Blwch offer ffenestri pop i fyny, yn y Blwch offer, cliciwch unrhyw un rheolydd a chliciwch ar y dde, yna dewiswch Rheolaethau Ychwanegol o'r ddewislen clicio ar y dde. Gweler y screenshot:

4. Yn y Rheolaethau Ychwanegol blwch deialog, sgroliwch i lawr i wirio'r Rheoli Microsoft MonthView opsiwn yn y Rheolaethau Ar Gael blwch, ac yna cliciwch ar y OK botwm.

5. Yna gallwch weld y MisView botwm yn cael ei ychwanegu yn y Blwch offer ffenestr. Cliciwch y botwm MonthView hwn, ac yna cliciwch ar y ffenestr UserForm1 i greu Calendr yn y Ffurflen Ddefnyddiwr.

Nodyn: Gallwch addasu maint y ffenestr UserForm i weddu i'r calendr a fewnosodwyd trwy lusgo ffin y UserForm.

6. Cliciwch ddwywaith ar y calendr a fewnosodwyd yn y UserForm1, ac yn y Côd ffenestr, disodli'r cod gwreiddiol gyda'r sgript VBA ganlynol.

VBA code: create a user form with calendar

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
 On Error Resume Next
   Dim xRg As Object
   For Each xRg In Selection.Cells
      xRg.Value = DateClicked
   Next xRg 
   Unload Me
End Sub

Nodyn: Gall y cod hwn helpu i fewnosod dyddiad mewn cell benodol ar ôl dewis dyddiad o'r calendr.

Cam 2: Ysgogi'r Calendr wrth glicio ar gell

Nawr mae angen i chi nodi rhai celloedd i ddangos y calendr wrth glicio. Gwnewch fel a ganlyn.

7. Cliciwch ddwywaith ar enw'r ddalen sy'n cynnwys y celloedd y byddwch chi'n eu clicio i naidlen yn y chwith Prosiect cwarel, yna copïwch a gludwch y cod VBA isod i mewn i ffenestr y Cod. Gweler y screenshot:

VBA code: Click cell to pop up calendar

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If (Target.Count = 1) Then
    If Not Intersect(Target, Range("A2:A10")) Is Nothing Then UserForm1.Show
    End If
End Sub

Nodyn: yn y cod, mae A2: A10 yn gelloedd y byddwch chi'n eu clicio i naidlen. Newidiwch yr ystod celloedd yn ôl yr angen.

8. Gwasgwch Alt + Q allweddi ar yr un pryd i gau'r Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

O hyn ymlaen, pan gliciwch ar unrhyw gell y tu mewn i'r ystod benodol yn y daflen waith gyfredol, bydd calendr yn ymddangos fel islaw'r screenshot a ddangosir. A bydd y dyddiad yn cael ei fewnosod yn awtomatig yn y gell a ddewiswyd ar ôl dewis dyddiad o'r calendr.


Codwch galendr wrth glicio cell benodol gyda chod VBA

Mae'r adran hon yn cyflwyno'r Dewiswr Dyddiad cyfleustodau Kutools ar gyfer Excel. Ar ôl galluogi'r nodwedd hon, cliciwch y bydd cell dyddiad yn popio calendr, gallwch chi ddisodli'r dyddiad presennol yn hawdd gyda dyddiad newydd gydag ef. Dilynwch y camau isod i gymhwyso'r nodwedd hon.

1. Cliciwch Kutools > Cynnwys > Galluogi Dewiswr Dyddiad.

2. Ar ôl galluogi'r nodwedd hon, cliciwch ar gell dyddiad, a bydd eicon calendr yn ymddangos i'r dde i'r gell.

3. Cliciwch yr eicon calendr i agor y Dewiswr Dyddiad blwch deialog, ac yna cliciwch ar ddyddiad newydd i ddisodli'r dyddiad mewn cell ddethol.

Nodiadau:

  • Dadwneud botwm: Cliciwch y botwm hwn i ddadwneud y dyddiad ailosod;
  • Botwm cau: Cliciwch y botwm hwn i gau'r blwch deialog Date Picker;
  • Dim ond i gelloedd sy'n cynnwys dyddiad y gall y nodwedd hon fod yn berthnasol.

  Os ydych chi am gael treial am ddim (30 diwrnod) o'r cyfleustodau hwn, cliciwch i'w lawrlwytho, ac yna ewch i gymhwyso'r llawdriniaeth yn ôl y camau uchod.


Erthyglau perthnasol:

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 (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am not seeing the Microsoft MonthView Control in the listing, but it may be as Pete (#32847) mentioned that this will not work in Office 365 or 64-bit Microsoft Office.
This comment was minimized by the moderator on the site
Hi Teagan Caudle,
I searched and tried the methods suggested in google, but ultimately could not register the MonthView control in Microsoft 365.
Sorry for the inconvenience. Maybe you can check this out.
https://social.technet.microsoft.com/Forums/Azure/en-US/db3b4dff-aad7-4d88-87cc-8f3f117be550/microsoft-windows-common-controls-60-for-office-2016
This comment was minimized by the moderator on the site
There is no Microsoft MonthView Control listed (Office 365), and the directions here doesn't explain how one would get that control, so this is pretty much useless unless you're using an older version of Excel.
This comment was minimized by the moderator on the site
The calendar will show up but when I click on the date, the cell doesn't populate
This comment was minimized by the moderator on the site
Hi,
The code works well in my case. Which Excel version are you using?
This comment was minimized by the moderator on the site
Thank you so much! These directions were super useful :)
This comment was minimized by the moderator on the site
Hi, Is it possible to put the date picker pop-up for multiple column, as in my sheet I have "start date", "end date" and "agreement date". if yes then how?
This comment was minimized by the moderator on the site
Hi jeet,
Follow the steps and replace the range "A2:A10" in the second VBA code with your column range (such as C2:E2).
This comment was minimized by the moderator on the site
Salve il codice funziona benissimo, ma se volessi farlo funzionare anche su un altro foglio
This comment was minimized by the moderator on the site
if i try to select a row, the pop up will activate and the date appears in each cell in that row


how can i avoid this
This comment was minimized by the moderator on the site
Hi Sam,
The code has been updated in the article with the problem solving. Please have a try and thank you for your comment.
This comment was minimized by the moderator on the site
tarihi seçebiliyorum ama a1:a10 hücrelerine seçtiğim tarih eklenmiyor. teşekkür ederim
This comment was minimized by the moderator on the site
Hello everyone,

Can anyone tell me how to popup a calendar in a range of cells, but starting only from the cell right bellow a table header and down bellow in an excel column.


Thank you in advance.
This comment was minimized by the moderator on the site
Use i.e: Range("B6:C30")
This comment was minimized by the moderator on the site
Good Day,
Sorry I didn't got your question. Would be nice if you could provide screenshot of what you are trying to do.
This comment was minimized by the moderator on the site
Use i.e: Range("B6:C30")
This comment was minimized by the moderator on the site
i used these VBA codes and everthing's fine so far. The range is A2:A10 and calendar pops up when you select a cell into it. But if you mark row from 2 to 10 again the calendar pops again. It's the same with column "A" if you mark it, again the calendar pops. How should i proceed, in order to get the calendar only in the range i've defined?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations