Update Data without repetition

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
204
Office Version
  1. 365
Platform
  1. Windows
Kindly help me with this
In sheet 1
A1:A600 has codes as follows
Example as below
subject_code

P
Bb,Bj
Bz
Pc
Ba,Mi
Bg,Xu
Xu,Xi
Xi,Xu
Xi
Xu,Bq
Bq,Bj,Xu

(There are many different codes - this is just a sample)

I want to update/add "Ms,Bq,Bg,Mh,Mi,Rg" from A1 through A600

The problem is some records already have one of the codes mentioned in

RULE = "Ms,Bq,Bg,Mh,Mi,Rg"

Say for example
If one of the data codes is already is in the rule then Add (codes that are absent in the data)

If
A1 has
Be,Bq - I want it to be updated as "Ms,Bq,Bg,Mh,Mi,Rg,Be" as one of the code Bq is already provided.

Example 2 - Xo,Xi
(New code + Rule)

Then it should be Ms,Bq,Bg,Mh,Mi,Rg,Xo,Xi

The idea is
"Ms,Bq,Bg,Mh,Mi,Rg" should be updated
If any of the code is already provided then it is retained and no double occurences should happen

Bq,Bs

Like Ms,Bq,Bg,Mh,Mi,Rg,Bs,Bq
(See Bq repeats twice)

I hope it is understandable. Thank you
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG29Apr09
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] r [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] r [COLOR="Navy"]In[/COLOR] Array("Ms", "Bq", "Bg", "Mh", "Mi", "Rg")
        [COLOR="Navy"]If[/COLOR] InStr(Dn, r) = 0 [COLOR="Navy"]Then[/COLOR]
            Dn = Dn & "," & r
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] r
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi MickG

Wow!! Unbelievable!!! That was like magic. Perfect desired output. Thank you for your effort.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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