Ask Experts Questions for FREE Help !
Ask
    Ben.O's Avatar
    Ben.O Posts: 3, Reputation: 1
    New Member
     
    #1

    Aug 17, 2010, 02:56 AM
    problem with my Excel-file / Conditional Format.
    Hey JB,
    I couldn't sing up to register at ExcelForum, where I found you account.
    I got a problem with my Excel-file / Conditional Format.
    I need 5 condititonal Formats. I almost used on of your VBA-codes (which you 'released' at excelforum.com).
    It works very good but not the way I need it.

    So I hope you can help me.
    I got a spread-sheet. F7 is the results from C7 x D7 x E7. L7 is the result from I7 x J7 x K7.
    Depending from the result the cell should be change his colour.
    If the result in F7/L7 is

    >320 = colour of the cell = red
    160-320 = color of the cell = orange
    70-160 = color of the cell = yellow
    20-70 = color of the cell = blue
    <20 = color of the cell = green

    I still hope you can help me.

    With kind regards from Germany,

    Ben
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Aug 17, 2010, 01:46 PM

    Hi Ben.

    GO ADVANCED and use the paperclip icon to post up a desensitized version of your workbook. We'll look at it together.
    Ben.O's Avatar
    Ben.O Posts: 3, Reputation: 1
    New Member
     
    #3

    Aug 18, 2010, 01:29 AM
    Hey JB,

    sorry for not posting my workbook.

    Well here it comes.

    As you can see, cell F7 and L7 are the results from C7xD7xE7 and
    I7xJ7xK7 so fare so good. The problem is that the cell doesn't change his color. When I wirte manual the result from C7xD7xE7 / I7xJ7xK7 in cell F7/L7 the colour of the cell is changing.

    In case that my file doesn't work here is my code I use.

    __________________________________________________ ________

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range
    For Each cell In Target
    If Not Intersect(cell, Range("F5:F1000,L5:L1000")) Is Nothing Then
    Select Case cell.Value
    Case 0 To 0, 1
    cell.Offset(0).Interior.ColorIndex = 2
    Case 0, 2 To 20
    cell.Offset(0).Interior.ColorIndex = 4
    Case 20, 5 To 70
    cell.Offset(0).Interior.ColorIndex = 5
    Case 70, 5 To 160
    cell.Offset(0).Interior.ColorIndex = 6
    Case 160, 5 To 320
    cell.Offset(0).Interior.ColorIndex = 46
    Case 320, 5 To 1000
    cell.Offset(0).Interior.ColorIndex = 3
    End Select
    End If
    Next cell

    __________________________________________________ ________

    I hope you can give me the answer to my problem.

    Take care,

    Ben
    Attached Files
  1. File Type: xls Mappe2.1.xls (67.5 KB, 180 views)
  2. JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #4

    Aug 18, 2010, 06:47 AM

    The intersect method only works to evaluate the exact cell that was changed by a user, you are trying to evaluate the numbers in cells that are changing by formulas.

    You can still use the WS_CHANGE event, but you'll have to evaluate the entire range of possible cells each time any value changes anywhere on the sheet. That could cause a noticeable lag,

    I've changed your macro to work with any change, but I've also adjusted the range of cells being evaluated so it only looks at the cells with actual formulas in them. This should keep it peppy.

    Code:
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range
    
    For Each cell In Range("F5:F1000,L5:L1000").SpecialCells(xlFormulas, xlNumbers)
        Select Case cell.Value
            Case 0 To 0, 1
                cell.Offset(0).Interior.ColorIndex = 2
            Case 0, 2 To 20
                cell.Offset(0).Interior.ColorIndex = 4
            Case 20, 5 To 70
                cell.Offset(0).Interior.ColorIndex = 5
            Case 70, 5 To 160
                cell.Offset(0).Interior.ColorIndex = 6
            Case 160, 5 To 320
                cell.Offset(0).Interior.ColorIndex = 46
            Case 320, 5 To 1000
                cell.Offset(0).Interior.ColorIndex = 3
        End Select
    Next cell
    
    End Sub
    Ben.O's Avatar
    Ben.O Posts: 3, Reputation: 1
    New Member
     
    #5

    Aug 19, 2010, 12:40 AM

    Hey JB,

    Thank very very very much.
    That's exactly what I was looking for.

    Take care,

    Ben

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Format cells with colors in Excel 2007 [ 2 Answers ]

Hello, I would like to format dynamically a column of cells with various colors in function of the day that is it written in the column before. For instance: Cells A1:A7 have "Monday;Tuesday;Wednesday;Thrusday;Friday;Saturday;Sunday" Cells B1:B7 will have what I will write in them but I...

Export access table to Excel format [ 1 Answers ]

Hi, I am trying following code its working fine. Private Sub Command3_Click() 'Export function 'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL 'REFERENCE TO DAO IS REQUIRED Dim strExcelFile As String Dim strWorksheet As String

Format Cells in Excel 2007 [ 4 Answers ]

Is there a way in Excel to automate adding hyphens in a specific position in a column of numbers (like a mac address list) For example: 0021e96c4183 00-21-e9-6c-41-83 HOWEVER When I use this method Home tab, Cell group, click on Format On Number tab from the Format Cells dialog screen I'd...

Excel Format [ 7 Answers ]

I need someone help. Everyday I need to format data like the following 1003, 1876, 1952, 2011, 2048, 2057, 2073, 2094, 2111, 2128 This gets pasted into one cell in a spreadsheet. I would like to be able to format it so it goes into the sheet 1003 1876 1952 etc into separate cells. Is this...


View more questions Search