need help getting names to match

kevin lazell

Well-known Member
Joined
Jun 2, 2004
Messages
513
hi guys i have failed miserably to get this to work i have attatched a snap shot of my worksheet with intended result being the 3rd box
what i need code to do is lookup first name in cell a2 and check to see if it is in b2 if it is then check if interior color in c2 matches c1 it does not
so then checks d2 and d1 now this matches so j2=j2+1 now we go back and check if a2 is in b3 then a2 is in b4 etc then the code will start all over again
now checking 2nd name in cell a3 with cell b2 and b3 and b4 and so on
i think the main problem is in checking the name when using key f8 to step through the code and hover over fnd it displays the four names
Annotation 2020-04-30 170547.png


Dim Fnd As Range
Dim a, x, name As Variant
a = 2: name = 2: x = 0
again:
x = x + 1

Set Fnd = Range("b:b").Find(Range("a" & name).Value, , , xlPart, , , False, , False)

If Fnd Is Nothing Then a = a + 1: GoTo again:






If Range("c" & a).Interior.ColorIndex = Range("c1").Interior.ColorIndex Then Range("i" & a) = Range("i" & a) + 1
If Range("d" & a).Interior.ColorIndex = Range("d1").Interior.ColorIndex Then Range("j" & a) = Range("j" & a) + 1
If Range("e" & a).Interior.ColorIndex = Range("e1").Interior.ColorIndex Then Range("k" & a) = Range("k" & a) + 1
If Range("f" & a).Interior.ColorIndex = Range("f1").Interior.ColorIndex Then Range("l" & a) = Range("l" & a) + 1
If Range("g" & a).Interior.ColorIndex = Range("g1").Interior.ColorIndex Then Range("m" & a) = Range("m" & a) + 1


a = a + 1
If x = 60 Then Exit Sub
If a = 12 Then a = 2: name = name + 1
GoTo again:
this is as far as i have got with the code a bit messy i know but just toying with it at the moment
any help will be greatly appreciated tia
 
just a quick question if you wouldnt mind
did i need to alter lastrow to lastrow2 or would it of
worked anyway thanks m8
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If column B is longer than column A then yes, you need lastrow2 otherwise, no.
 
Upvote 0
i believe i am getting good at this excel lark lol
thanks again snakehips you have been brilliant!!!!
good luck and stay safe m8
 
Upvote 0
i believe i am getting good at this excel lark lol
thanks again snakehips you have been brilliant!!!!
good luck and stay safe m8

Yes. I will know where to come, if I get stuck!?
You are welcome.
And you!!
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

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