Skip i'r prif gynnwys

Sut i ddidoli dyddiad pan fydd y dyddiad yn cael ei nodi neu ei newid yn Excel? 

Yn Excel, mae'r Trefnu yn gall swyddogaeth eich helpu i ddidoli dyddiad yn nhrefn esgynnol neu ddisgynnol yn ôl yr angen. Ond nid yw'n ddeinamig, os ydych chi wedi didoli'r dyddiad ac yna ychwanegu dyddiad newydd ato, byddai angen i chi ei ddidoli eto. A oes unrhyw ffyrdd da a chyflym ichi ddidoli'r dyddiad wrth nodi dyddiad newydd bob tro mewn taflen waith?

Dyddiad didoli awto pan fydd y dyddiad yn cael ei nodi neu ei newid gyda'r fformiwla

Dyddiad didoli awto pan fydd y dyddiad yn cael ei nodi neu ei newid gyda chod VBA


swigen dde glas saeth Dyddiad didoli awto pan fydd y dyddiad yn cael ei nodi neu ei newid gyda'r fformiwla

Er enghraifft, y dyddiad gwreiddiol yng Ngholofn A, gall y fformiwla ganlynol eich helpu chi i ddidoli'r dyddiad neu unrhyw dannau testun eraill mewn colofn cynorthwyydd newydd yn seiliedig ar y golofn rydych chi am ei didoli, gwnewch fel a ganlyn:

1. Rhowch y fformiwla hon:

=INDEX($A$2:$A$15,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$15,"<="&$A$2:$A$15),0)) i mewn i gell wag wrth ymyl eich colofn dyddiad, C2, er enghraifft, ac yna pwyswch Ctrl + Shift + Enter allweddi gyda'i gilydd, a byddwch yn cael dilyniant rhif, yna llusgwch y ddolen llenwi i lawr i'r celloedd rydych chi am eu defnyddio, gweler y screenshot:

Nodyn: Yn y fformiwla uchod: A2: A15 yw eich ystod dyddiad gwreiddiol yr ydych am ei ddidoli yn awtomatig.

doc autosort erbyn dyddiad 1

2. Yna fformatiwch y rhifau fel fformat dyddiad trwy glicio Dyddiad Byr oddi wrth y cyffredinol rhestr ostwng o dan y Hafan tab, gweler y screenshot:

doc autosort erbyn dyddiad 2

3. Yna mae'r rhifau dilyniant wedi'u trosi i fformat dyddiad, ac mae'r dyddiad gwreiddiol wedi'i ddidoli hefyd, gweler y screenshot:

doc autosort erbyn dyddiad 3

4. O hyn ymlaen, pan fyddwch chi'n nodi dyddiad newydd neu'n newid y dyddiad yng ngholofn A, bydd y dyddiad yng ngholofn C yn cael ei ddidoli yn nhrefn esgynnol yn awtomatig, gweler y screenshot:

doc autosort erbyn dyddiad 4


swigen dde glas saeth Dyddiad didoli awto pan fydd y dyddiad yn cael ei nodi neu ei newid gyda chod VBA

Gall y cod VBA canlynol eich helpu i ddidoli'r dyddiad yn y golofn wreiddiol pan fyddwch chi'n nodi dyddiad newydd neu'n newid y dyddiad yn ôl yr angen.

1. Ewch i'r daflen waith rydych chi am ei didoli'n awtomatig pan fyddwch chi'n nodi neu'n newid dyddiad.

2. De-gliciwch y tab dalen, a dewis Gweld y Cod o'r ddewislen cyd-destun, yn y popped allan Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, copïwch a gludwch y cod canlynol i'r gwag Modiwlau ffenestr, gweler y screenshot:

Cod VBA: didoli auto pan fydd y dyddiad yn cael ei nodi neu ei newid:

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
    On Error Resume Next
    If Application.Intersect(Target, Application.Columns(1)) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    Range("A1").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
                                        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

doc autosort erbyn dyddiad 6

Nodyn: Yn y cod uchod, bydd y dyddiad a gofnodwyd yn cael ei ddidoli'n awtomatig yng ngholofn A, gallwch newid A1 ac A2 i'ch celloedd eich hun yn ôl yr angen.

3. O hyn ymlaen, pan nodwch y dyddiad yng ngholofn A, bydd y dyddiad yn cael ei ddidoli yn esgyn yn awtomatig.

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 (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,This is a great tool. thank you. How can i apply this to multiple columns in the same tab? Could i apply it to restart sorting by date in a new cell of the same column? Would i just repaste the VBA code into the same window?
Thank you.
This comment was minimized by the moderator on the site
Hello Noname9,How are you? To achieve your goal by using VBA code is beyond my reach. But I do know how to use formulas to do the trick.Suppose we have two columns of dates, say A2:B7. How to sort these dates into a new column? Please do as follows.
First, we need to combine the two columns of dates into one column. Copy and paste the formula =INDEX($A$2:$B$7,INT((ROWS(D$2:D2)-1)/2)+1,MOD(ROWS(D$2:D2)-1,2)+1) into cell D2. And drag the fill handle down to combine all dates. Please see screenshot 1.
Then, we will sort the combined dates. Copy and paste the formula =INDEX($D$2:$D$13,MATCH(ROWS($D$2:D2),COUNTIF($D$2:$D$13,"<="&$D$2:$D$13),0)) into F2. And drag the fill handle down to sort all dates. Please see screenshot 2.
Hope it will help. Have a nice day.Sincerely,Mandy
This comment was minimized by the moderator on the site
Hello,What if i want to do this to multiple columns or even have anew start point in the same column? Do i just do a break and recopy the VBA code in that same window?
Thank you.
This comment was minimized by the moderator on the site
That VBA code is solid gold! Thank you! :-)
This comment was minimized by the moderator on the site
With the VBA code, I have copy and pasted the above but wish for the dates in column F to be the values by which the data is sorted. I've changed the range values to F2 and F3500 (the size of the spreadsheet where row 1 is titles), but it still sorts by the dates in column A. Can somebody help me please?
This comment was minimized by the moderator on the site
Hello, Ross,
When applying the code to column F, you should change some references to your need as below code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice 20160606
On Error Resume Next
If Application.Intersect(Target, Application.Columns(6)) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
Range("F1").Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Is there a particular formula to keep the cells following the sorted date? It would be nice to organize by date but keep the entire row of information. Any help would be much appreciated.
This comment was minimized by the moderator on the site
I mad a checkbook register and it works but I want to figure out how to make my entry’s to go into date order. Any help would be appreciated. I’m still learning excel.
This comment was minimized by the moderator on the site
In addition to the duplicate dates, is there also a way to include multiple columns of data when it sorts? I need it to include multiple columns and sort them all together with the expiration dates.
This comment was minimized by the moderator on the site
how can I do this same sorting calculation but from newest date to oldest? Currently it is Oldest to Newest. Flipping the < sign isn't enough and beyond that I don't have a strong enough understanding of what it is doing. Also I think what may be happening is excel automatically works top to bottom causing difficulties.
This comment was minimized by the moderator on the site
Hello, Bo,

To auto sort the date from newest to oldest, you just need to change the <= to >= in the above formula as follows:
=INDEX($A$2:$A$15,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$15,">="&$A$2:$A$15),0))
After inserting this formula, please remember to press Ctrl + Shift + Enter keys together to get the correct result.
Please try it.
This comment was minimized by the moderator on the site
What if there is a duplicate date in the list? And I want both numbers to show up.
This comment was minimized by the moderator on the site
Hello, Ryan,

To sort the date with duplicate ones, you should apply the following formula:

=IFERROR(INDEX($A$2:$A$11,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$11,"<="&$A$2:$A$11),0)),IF(ROWS($A$2:A2)<ROWS($A$2:$A$11),B3,""))

Please remember to press Shift + Ctrl + Enter keys together.

Hope it can help you, thank you!
This comment was minimized by the moderator on the site
Awesome :) Working fine
This comment was minimized by the moderator on the site
U forgot to mention the formula is array and you need to ctrl+Shift+ enter. Luckily you had a screenshot or your page would be a waste of cyberspace
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations