IF Statements

BenNV

Board Regular
Joined
Mar 27, 2002
Messages
160
Thanks for all the support the forum has given me so far and sorry for asking so many questions. I am new to the capabilities of Excel/VBA and so far, I'm very impressed. I have another query I was hoping for some help on:

With the help of Dave and Tom, below is a way of permanently highlighting a row if two cells match, even if the workbook is inactive.

Private Sub Worksheet_Calculate()
If Range("D1") = Range("E5") Then
Range("A5:L5").Select
With Selection.Interior
.ColorIndex = 45
.Pattern = xlSolid
End With
End If
End Sub


I now need to use several “if” statements to match conditions. Below explains:
My data all starts on row 5. And is labelled A to L.
If column G = “NDT” and the value in H or I equals D1 then do the above in the code.
If column G = “TO” and the value in E equals D1 then do the above code.
If column G = “ROCK” and column F = “X” and then value in I equals D1, then do the above code.
If column G = “ROCK” and column F = “O” and the value in H equals D1, then do the above code.
If column G = “BX” and column F = “X” and the value in H equals D1, then do the above code.
If column G = “BX” and column F = “O” and the value in I equals D1, then do the above code.

A few adjustments need to be made to the above. Instead of selecting A5:L5, I need to select the row which matches the above condition. The worksheet can have numerous rows with data. So the above code only mentions one row not the rest. I suppose I'll need a row counter or anything else you can suggest.

Thank You.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

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