Consulting

Results 1 to 5 of 5

Thread: Formatconditions for dynamic range

  1. #1
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location

    Formatconditions for dynamic range

    Hey guys,

    Having a bit of an issue trying to set a conditional format via code for a group of cells. What I'm trying to do is have the entire row highlight grey if column C contains an #N/A error.

    I've got this so far:
    .Cells.FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=ISNA($C1)"
    There doesn't seem to be an R1C1 method for this that I've found yet though...

    Any ideas?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    How about a WorkSheet Change event

    If Not Columns(3).EntireColumn.Find(What:="#N/A", LookIn:=xlValues, _
     SearchDirection:=xlNext) Is Nothing Then
    Columns(3).EntireColumn.Interior.ColorIndex = 15
    Else
    Columns(3).EntireColumn.Interior.ColorIndex = xlNone
    End If
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hey Malcolm,

    Thanks. I've never had much success using the Find method... somthing about it just doesn't like me.

    A different path just occured to me, though! I hit it with an autofilter then coloured the visible cells using the specialcells method. Works a treat!

    Thanks for the input though!
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Ken,

    So, what is the problem with the code?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hi Bob!

    It sets
    =ISNA($C1) for every cell. Doesn't change for each row. In row 2, I need it to be C2, etc...

    No biggie, as I have a workaround, but something tells me I should be able to set a conditional format to do this by coding it.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

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