Change of font colour

newvbie

Board Regular
Joined
Mar 18, 2006
Messages
69
Hi there. I got an Excel worksheet containing a column of hourly wage. I also got the following script to detect the wage level so that user will be alert to those lower wages.

Private Sub Worksheet_Change(ByVal Target As Range)
For k = 2 To 31
If Sheet32.Cells(k, 42).Value < 29 Then # where 29 is minimum wage
Sheet32.Cells(k, 42).Font.ColorIndex = 3 # wage will be change to Red
ElseIf Sheet32.Cells(k, 42).Value >= 29 Then
Sheet32.Cells(k, 42).Font.ColorIndex = 10 # where wage will remain green
End If
Next
End Sub


However, whenever there is change in the wage, it prompts me with a error message saying there is something wrong with the property of the Font colour index. Did I miss something?

Thanks.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Code:
Sheet32.Cells(k, 42).[B][COLOR="Red"]Interior[/COLOR][/B].Font.ColorIndex=10
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

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