+ Reply to Thread
Results 1 to 2 of 2

Apply conditional formatting using VBA which refers to cells on the currently selected row

Hybrid View

Salbrox Apply conditional formatting... 06-12-2013, 12:16 PM
Salbrox Re: Apply conditional... 06-12-2013, 12:23 PM
  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    2

    Unhappy Apply conditional formatting using VBA which refers to cells on the currently selected row

    Hi folks,

    This issue has me nearly tearing my hair out. Can't see what I'm doing wrong. Not really experienced enough in Excel VBA i guess. Anyway here is my code:

        
        
        With ActiveCell
        
            Dim rng As Range
            Dim O As String
            Dim P As String
            Dim Q As String
            
            Range(Cells(.Row, "R"), Cells(.Row, "FQ")).Select
            
            Set rng = Range(Cells(.Row, "R"), Cells(.Row, "FQ"))
            
            O = Chr(34) & "=$O&" & ActiveCell.Row & Chr(34)
            P = Chr(34) & "=$P&" & ActiveCell.Row & Chr(34)
            Q = Chr(34) & "=$Q&" & ActiveCell.Row & Chr(34)
            
            rng.FormatConditions.Delete
            
            With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:=O)
                .Interior.Color = rgbBlue
            End With
            
            With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:=P)
                .Interior.Color = rgbGreen
            End With
            
            With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:=Q)
                .Interior.Color = rgbPurple
            End With
        
        End With
    It should be applying conditional formatting to the range but when i run the code and check the Conditional formatting window afterwards, all I get is this:

    Cell value = "="
    Cell value = "="
    Cell value = "="

    Why is this happening?

    Any help much appreciated!

  2. #2
    Registered User
    Join Date
    06-12-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Apply conditional formatting using VBA which refers to cells on the currently selected

    Ignore this! There was no issue i was looking at the wrong sheet! My apologies for wasting anyones time!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1