How to write VBA code for Sort First 3 Months Data in Nse Future EOD Bhav Excel Files ?

Dear All,

I am trying to make EOD Downloader for Download Bhav Copy Files from Nse site and import to Amibroker - using in Excel.

I have Some Doubt. Can any one Clear this to me?

Here I have Attached Sample Option Market Eod File Screen Shot.

I like to Filter First 3 Months Data only in C Column (EXPIRY_DT).

After Filter First 3 Months Data and Change that expiry date to I , II , III.

Example :

[First we must sort for view only First 3 months Data. Anyone Jan,Feb and Mar or Feb,Mar and Apr]

Instrument Name | Symbol | Expiry_dt
Opdidx | Nifty | 30-Jan-20
Opdidx | Nifty | 27-Feb-20
Opdidx | Nifty | 26-Mar-20

After Sorted should change 30-Jan-20 Date to - I, 27-Feb-20 to -II and 26-Mar-20 to - III.

The above Process should do in VBA Code (Macro).

Can any one help me to create this ?

Thanks in Advance.

Last edited:


Well-Known Member
month character names cannot be sorted correctly.

Convert option expiry date to yyyymmdd format and sort on that. Entire sort string would be <Symbol><CEPE><Strike><exipry_yyyy><expiry_mm><expiry_dd>