[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

adapting code

Asked by pete47 in Microsoft Excel Spreadsheet Software

can the code below be adapted so that instead of letters being compared and coloured red, yellow or green, numbers are. numbers from 1-9. 9 being the highest, 1 being the lowest. some numbers will appear with a letter attached, like 5a. in that case 5b would be lower and therefore coloured red. 5a, 5b, 5c 5a is high, 5c is low
5a-5a = yellow
5c-5a coloured green
5c-6 coloured green
4 - 6 = green
6-4 = red.
hope ive been clear. im knackered at the moment
pete
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
Sub colorz()
 
Application.ScreenUpdating = False
 
For i = 16 To 200
    For j = 5 To 102 Step 3
            
            Cell1 = Cells(i, j)
            Cell2 = Cells(i, j + 1)
            
            If Cell1 = "" Or Cell2 = "" Then
                Cells(i, j).Interior.color = vbWhite
                Cells(i, j + 1).Interior.color = vbWhite
                GoTo Skip
            End If
            
            If Len(Cell1) > 1 Then
                A = 255 - Asc(Left(Cell1, 1)) + Asc(Mid(Cell1, 2, 1)) / 1000
            Else
                A = 255 - Asc(Left(Cell1, 1))
            End If
            
            If Len(Cell2) > 1 Then
                b = 255 - Asc(Left(Cell2, 1)) + Asc(Mid(Cell2, 2, 1)) / 1000
            Else
                b = 255 - Asc(Left(Cell2, 1))
            End If
            
            
            If A > b Then
                Cells(i, j).Interior.color = vbRed
                Cells(i, j + 1).Interior.color = vbRed
            End If
            If A = b Then
                Cells(i, j).Interior.color = vbYellow
                Cells(i, j + 1).Interior.color = vbYellow
            End If
            
            If A < b Then
                Cells(i, j).Interior.color = vbGreen
                Cells(i, j + 1).Interior.color = vbGreen
            End If
 
Skip:
            
    Next j
Next i
 
Application.ScreenUpdating = True
 
End Sub
[+][-]09/26/09 03:23 PM, ID: 25431841Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/27/09 05:52 AM, ID: 25433874Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/27/09 08:44 AM, ID: 25434259Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625