excel macro If and and and or then

Hello expert,
please can you help me

If C column have 0000 and D column=1 and E column=2 and A column 3 or 5 then sum B column +18 and then result put in C column and color yellow

If C column have 0000 and D column=1 and E column=2 and A column 4 or 6 then sum B column +21 and if sum B column+21=<2006 put 2006 in C column and if is not put result in C column and color green.

thx.
saricsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
A sample workbook with desired output would be helpful.
0
saricsAuthor Commented:
0
Rgonzo1971Commented:
Hi,

pls try

Sub macro()

For Each c In Range(Range("C2"), Range("C" & Cells.Rows.Count).End(xlUp))
    If c = 0 And c.Offset(0, 1) = 1 And c.Offset(0, 2) = 2 Then
        If c.Offset(0, -2) = 3 Or c.Offset(0, -2) = 5 Then
            c.Value = c.Offset(0, -1) + 18
            c.Interior.Color = vbYellow
        ElseIf c.Offset(0, -2) = 4 Or c.Offset(0, -2) = 6 Then
            c.Value = Application.Max(2006, c.Offset(0, -1) + 21)
            c.Interior.Color = RGB(146, 208, 80)
        End If
    End If
Next
End Sub

Open in new window

Regards
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saricsAuthor Commented:
Thank you, you 're a magician :-) work perfectly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.