Auto Sort (Descinding) based on a column header using VBA

KSKWin

New Member
Joined
May 7, 2023
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
I have an excel with professional data, I want to Auto sort (descending) based on a column header (Experience), also if on entering new record it should auto sort accordingly, on completing the entries,
Column A to E, is the entry field, and Column H to J are only display columns.

Pl. help is providing the VBA code to this request.

Thank you
KSK
Auto Sort.xlsx
ABCDEHIJ
2S.NoBirth NameStart DateEnd DateTodayExperience
31Names 101-Jan-902-Mar-041421
41Names 201-Jan-7501-Jan-063-Mar-043100
51Names 301-Jan-854-Mar-041923
61Names 401-Jan-895-Mar-041524
71Names 501-Nov-956-Mar-04845
81Names 61-Jan-987-Mar-04626
91Names 701-Jan-9601-Jan-108-Mar-041400
101Names 801-Jan-8601-Jan-949-Mar-04800
111Names 901-Jan-8701-Jan-0410-Mar-041700
121Names 1001-Jan-9801-Jan-1511-Mar-041700
131Names 1101-Jan-9801-Jan-0812-Mar-041000
141Names 1201-Jan-7913-Mar-0425212
151Names 1301-Jan-9701-Jan-9914-Mar-04200
161Names 141-Jan-821-Jan-9915-Mar-041700
171Names 151-Jan-9516-Mar-049215
181Names 161-Jan-9617-Mar-048216
191Names 171-Jan-9518-Mar-049217
201Names 181-Jan-9719-Mar-047218
211Names 1901-Jan-0120-Mar-043219
221Names 2001-Jan-0321-Mar-041220
231Names 2101-Jan-0422-Mar-040221
241Names 2201-Jan-0223-Mar-042222
251Names 2301-Jan-9924-Mar-045223
26125-Mar-04104225
27126-Mar-04104226
28127-Mar-04104227
29128-Mar-04104228
30129-Mar-04104229
31130-Mar-04104230
32131-Mar-04104231
3311-Apr-0410431
3412-Apr-0410432
3513-Apr-0410433
3614-Apr-0410434
3715-Apr-0410435
3816-Apr-0410436
3917-Apr-0410437
4018-Apr-0410438
4119-Apr-0410439
42110-Apr-04104310
43111-Apr-04104311
44112-Apr-04104312
45113-Apr-04104313
46114-Apr-04104314
47115-Apr-04104315
48116-Apr-04104316
49117-Apr-04104317
50118-Apr-04104318
51119-Apr-04104319
Person
Cell Formulas
RangeFormula
H3:H51H3=IF(NOT(ISBLANK(D3)),DATEDIF(C3,D3,"y"),DATEDIF(C3,E3,"y"))
I3:I51I3=IF(NOT(ISBLANK(D3)),DATEDIF(C3,D3,"ym"),DATEDIF(C3,E3,"ym"))
J3:J51J3=IF(NOT(ISBLANK(D3)),DATEDIF(C3,D3,"md"),DATEDIF(C3,E3,"md"))
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Auto Sort (Descinding) based on a column header using VBA
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top