Check if cell input matches another cell input from list

Bona_Excel

New Member
Joined
Nov 19, 2021
Messages
2
Platform
  1. Windows
I'm new to coding with excel vba, but i have an excel map with a list of superiors and a list of potential successor. Now i got the task to create an excel map where you can put in the position of a superior into an Input Box and it should automatically show you the successors that fit based on their current position e.g. only heads of departments can become CEO or in this case "FM" position can only be filled by "AL" and "MM".

VBA Code:
For Each Column1 In Range("D3:D6").Columns
For Each cell1 In Column1.Cells
For Each Column2 In Range("N3:N6").Columns
For Each cell2 In Column2.Cells

If cell1.Value = "MM" And cell2.Value = "AL" Or cell2.Value = "MM Asp." Or cell2.Value = "Tagesvertretung" Or cell2.Value = "MM-Stv." Or cell2.Value = "VM" Or cell2.Value = "FM" Then
cell2.Interior.ColorIndex = 10
ElseIf cell1.Value = "FM" And cell2.Value = "AL" Or cell2.Value = "MM" Then
cell2.Interior.ColorIndex = 10
ElseIf cell1.Value = "VM" And cell2.Value = "MM" Then
cell2.Interior.ColorIndex = 1
ElseIf cell1.Value = "VL" And cell2.Value = "VM" Or cell2.Value = "FM" Then
cell2.Interior.ColorIndex = 10
ElseIf cell1.Value = "VD" And cell2.Value = "VM" Or cell2.Value = "FM" Or cell2.Value = "VL" Then
cell2.Interior.ColorIndex = 10
ElseIf cell1.Value = "MM-Stv." And cell2.Value = "AL" Then
cell2.Interior.ColorIndex = 10
Else
cell2.Interior.ColorIndex = 3
End If

Next
Next
Next
Next

Theoretically it does what i want it to although it either colors the cells wrong or it only changes the color of the whole range (N3:N6) when i change the last cell (N6)
Thanks in advance for your help
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,817
Messages
6,181,147
Members
453,021
Latest member
Justyna P

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