Find Group VBA require

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000

Hi,

I have 4 groups
C1:C2 = Group A = 7 &7
D1:D2 = Group B = 7 &Z
E1:E2 = Group C = Z &7
F1:F2 = Group D = Z &Z

C7:F9 I have got data, I want results in H6:K9

Example how it works... with row 5 & 6
Cells C5, C6 = 7 & 7 result in H6 = A (because it belong to group A)
Cells D5, D6 = 7 & Z result in I6 = B (because it belong to group B)
Cells E5, E6 = Z & 7 result in J6 = C (because it belong to group C)
Cells F5, F6 = Z & Z result in K6 = D (because it belong to group D)

Example how it works... with row 6 & 7
Cells C6, C7 = 7 & Z result in H7 = B (because it belong to group B)
Cells D6, D7 = Z & 7 result in I7 = C (because it belong to group C)
Cells E6, E7 = 7 & Z result in J7 = B (because it belong to group B)
Cells F6, F7 = Z & Z result in K7 = D (because it belong to group D)

And will continue as same procedure with rest row till to end

Sheet example

Book1
ABCDEFGHIJK
177ZZ
27Z7Z
3Group-->ABCD
4n1n2n3n4
577ZZ
67Z7ZABCD
7Z7ZZBCBD
8Z777DACC
97ZZZCBBB
10
11
Sheet1


Thank you in advance

Regards,
Kishan
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Nov45
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("C6"), Range("C" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]For[/COLOR] Ac = 0 To 3
       [COLOR="Navy"]For[/COLOR] n = 0 To 3
            [COLOR="Navy"]If[/COLOR] Dn.Offset(-1).Offset(, Ac) & Dn.Offset(, Ac).Value _
                 = Cells(1, 3).Offset(, n) & Cells(2, 3).Offset(, n) [COLOR="Navy"]Then[/COLOR]
                Dn.Offset(, 5 + Ac).Value = Cells(3, 3).Offset(, n).Value
                [COLOR="Navy"]Exit[/COLOR] For
            [COLOR="Navy"]End[/COLOR] If
      [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG19Nov45
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, Ac [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] n [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range(Range("C6"), Range("C" & Rows.Count).End(xlUp))
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
    [COLOR=navy]For[/COLOR] Ac = 0 To 3
       [COLOR=navy]For[/COLOR] n = 0 To 3
            [COLOR=navy]If[/COLOR] Dn.Offset(-1).Offset(, Ac) & Dn.Offset(, Ac).Value _
                 = Cells(1, 3).Offset(, n) & Cells(2, 3).Offset(, n) [COLOR=navy]Then[/COLOR]
                Dn.Offset(, 5 + Ac).Value = Cells(3, 3).Offset(, n).Value
                [COLOR=navy]Exit[/COLOR] For
            [COLOR=navy]End[/COLOR] If
      [COLOR=navy]Next[/COLOR] n
    [COLOR=navy]Next[/COLOR] Ac
[COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
Thank a lot Mick, cannot believe, but I have to say it is giving a desire results as I wanted.

Good Luck and have a nice Sunday

Regards,
Kishan

 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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