count the duplicate entries with the help of Macro

chirag_patel5141

New Member
Joined
Jun 4, 2016
Messages
10
Hi All,
I want to Count the Duplicate entries in the column "SYMBOL" with the refeance of column "EXPIRY_DT" and also want to number them like...
IF 31-Mar-16 than BANKNIFTY-I , 28-Apr-16 than BANKNIFTY-II & 26-MAY-16 than BANKNIFTY-III


INSTRUMENT"SYMBOL""EXPIRY_DT"OPENHIGHLOWCLOSEOPEN_INTCHG_IN_OI"TIMESTAMP"
FUTIDXBANKNIFTY31-Mar-161574515965.71574015941.55235035019428021-Mar-16
FUTIDXBANKNIFTY28-Apr-1615816160361581616017.552942102301021-Mar-16
FUTIDXBANKNIFTY26-May-1615876.116049.951585016042.9510449084021-Mar-16
FUTIDXDJIA13-Apr-161746017512.51744017507.516950306021-Mar-16
FUTIDXDJIA20-May-16000167400021-Mar-16
FUTIDXDJIA17-Jun-160001638530021-Mar-16
FUTIDXDJIA16-Sep-1600016702.530021-Mar-16
FUTIDXDJIA16-Dec-16000188350021-Mar-16
FUTIDXDJIA17-Mar-17000189650021-Mar-16
FUTIDXFTSE10013-Apr-166398639863986398757521-Mar-16
FUTIDXFTSE10020-May-1600060910021-Mar-16
FUTIDXFTSE10017-Jun-1600072420021-Mar-16
FUTIDXFTSE10016-Sep-1600066370021-Mar-16
FUTIDXFTSE10016-Dec-1600065700021-Mar-16
FUTIDXFTSE10017-Mar-1700067280021-Mar-16
FUTIDXNIFTY31-Mar-167623.57723.27615.27713.3521508425-75180021-Mar-16
FUTIDXNIFTY28-Apr-167664.97761.47658.47750.8429090039157521-Mar-16
FUTIDXNIFTY26-May-167677.457773.47672.157763.710754257777521-Mar-16
FUTIDXNIFTYINFRA31-Mar-160002565150021-Mar-16
FUTIDXNIFTYINFRA28-Apr-160002440.950021-Mar-16
FUTIDXNIFTYINFRA26-May-160002330.450021-Mar-16

<tbody>
</tbody>
 
In above example If Symbol of BANKNIFTY comes with any other EXPIRY_DT (date), for example 29-Sep-16 than the New Symbol will be BANKNIFTY-IV ..
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG06Jun39
[COLOR="Navy"]Dim[/COLOR] Dn      [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Rng     [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dic     [COLOR="Navy"]As[/COLOR] Object
[COLOR="Navy"]Dim[/COLOR] k       [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] p       [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] c       [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
 
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
 [COLOR="Navy"]Set[/COLOR] Dic = CreateObject("Scripting.Dictionary")
    Dic.CompareMode = 1
   [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
            [COLOR="Navy"]If[/COLOR] Not Dic.exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
                [COLOR="Navy"]Set[/COLOR] Dic(Dn.Value) = CreateObject("Scripting.Dictionary")
            [COLOR="Navy"]End[/COLOR] If
        
        [COLOR="Navy"]If[/COLOR] Not Dic(Dn.Value).exists(Dn.Offset(, 1).Value) [COLOR="Navy"]Then[/COLOR]
                Dic(Dn.Value).Add (Dn.Offset(, 1).Value), Dn
        [COLOR="Navy"]Else[/COLOR]
                [COLOR="Navy"]Set[/COLOR] Dic(Dn.Value).Item(Dn.Offset(, 1).Value) = _
                Union(Dic(Dn.Value).Item(Dn.Offset(, 1).Value), Dn)
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] k [COLOR="Navy"]In[/COLOR] Dic.Keys
       c = 0
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] p [COLOR="Navy"]In[/COLOR] Dic(k)
        c = c + 1
         [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Dic(k).Item(p)
           Dn.Value = Dn.Value & "-" & WorksheetFunction.Roman(c)
         [COLOR="Navy"]Next[/COLOR] Dn
    [COLOR="Navy"]Next[/COLOR] p
[COLOR="Navy"]Next[/COLOR] k
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,216,153
Messages
6,129,180
Members
449,491
Latest member
maxim_sivakon

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