Change cell to color, just need little help

cfer

Well-known Member
Joined
Jul 29, 2002
Messages
560
Hi,

Found some code from way back, thanks to Nimrod, that almost worked for me. Works fine as it is below.

Where the case statement reads Case 90 To 100 'A, I want to substitue the 90 To 100 with a leter ie x The same for the others, but have f t s.

When I change it to an x, I get a green color, I pres the Delete key I get a green cell, If I change all the cases to a different letter, and color number, I only get a green cell still.

The Code from Nimrod, that I am trying to adapt, my little cooment to the side , is below

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

With Target
If .Column = 1 Then
Select Case Val(.Value)
Case 90 To 100 ' A I want this to be an x
.Interior.ColorIndex = 4
Case 80 To 89 ' B I want this to be an f
.Interior.ColorIndex = 6
Case 70 To 79 ' c I want this to be an s
.Interior.ColorIndex = 8
Case 60 To 69 ' D I want this to be an p
.Interior.ColorIndex = 7
Case 1 To 59 ' F I want this to be an t
.Interior.ColorIndex = 5
Case Else 'reset to default if non of above
.Interior.ColorIndex = xlNone
.Font.ColorIndex = 0
End Select
End If
End With
End Sub

Any suggestions please.

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try changing
Select Case Val(.Value)

to

Select Case .Value

then Change the Case statements to

Case "x"
Case "f"

etc.

disclaimer. (I have not tested this suggestion)
 
Upvote 0
If you are using a change event, use

Select Case Target
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target
    Case "f"
        'somecode
    Case "t"
    'etc
    End Select
End Sub

lenze
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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