Excel vba to color row based on wbs level

Posts
5
Registration date
Tuesday August 20, 2019
Status
Member
Last seen
August 26, 2019
- - Latest reply: ac3mark
Posts
12974
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
September 10, 2019
- Aug 21, 2019 at 02:30 PM
Hello
I need a macro to change row color based on "Level" column.

Thanks
Ebti
See more 

1 reply

Posts
12974
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
September 10, 2019
1366
0
Thank you
Here is a simple one. It looks for "one" in cell A of each row.

Sub colortherow ()
Thecounter=findlastrow ("yoursheet")
for each RC in Range ("A1:A"& thecounter)
If RC.value ="one" then
RC.entirerow.interior.color=vbRed
End if
Next
End sub

Function findlastrow (whatsheet)
Findlastrow=thisworkbook.worksheets(whatsheet).cells.(rows.count,1).end (xlUp).row
End function

Very simple.
Respond to ac3mark