+ Reply to Thread
Results 1 to 9 of 9

Conditional Formatting in VBA

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    235

    Conditional Formatting in VBA

    Hi Guys,

    What VBA codes should i put when i need to conditional formatting A1:A10 if their is text specific "#N/A" in white font and white background?

    thanks guys!

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Conditional Formatting in VBA

    Why do you want to do it using VBA? You can do it using Conditional Formatting or even better using an IFERROR in front of your formula in these cells, forcing your formula to don;t gives to you #N/A values..
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Conditional Formatting in VBA

    same query as fotis but if you really want it to be done i did something similar recently

    http://www.excelforum.com/excel-prog...91#post3335591
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    235

    Re: Conditional Formatting in VBA

    sorry for the confusion.

    im currently working on some VBA template and there is a DATA that is paste value as #N/A and i just need to code it on vba when the code finds #N/A on my data it will automatically white their fonts and background as well.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Conditional Formatting in VBA

    oK. I am not able to help you using VBA. I hope someone will be able to do this. But i suggest you to pm an online Moderator to moove your thread in VBA section.

    DON'T start a new thread. It's will be a duplicate thread..

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Conditional Formatting in VBA

    to get white background
    .Interior.colorindex = 2

    to get white font
    .Font.colorindex = 2

    Sub ConditionalFormat()
        Dim I As Integer
        I = 1
        For I = 1 To 10
            If IsError(Cells(I, 1).Value) = True Then
                Cells(I, 1).Interior.ColorIndex = 2
                Cells(I, 1).Font.ColorIndex = 2
            End If
        Next I
    End Sub
    Last edited by humdingaling; 07-25-2013 at 05:12 AM. Reason: based on error and not text "N/A"

  7. #7
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    235

    Re: Conditional Formatting in VBA

    thanks it is now working! whohoooo!

  8. #8
    Registered User
    Join Date
    02-19-2013
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    71

    Re: Conditional Formatting in VBA

    Or else u can use ISNA function, because this is mainly designed to handle #N/A error value.

    For i = 1 To 10
    If Application.WorksheetFunction.IsNA(ActiveCell.Value) = True Then
    ActiveCell.Interior.Color = vbWhite
    ActiveCell.Font.Color = vbWhite
    ActiveCell.Offset(1, 0).Select
    Else
    ActiveCell.Offset(1, 0).Select
    End If
    Next

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Conditional Formatting in VBA

    janagan,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Conditional Formatting via VBA: Change formatting in range based on value of each cell
    By ralphjmedia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 10:37 AM
  2. Delete Conditional Formatting conditions but keep cell formatting - Excel 2010
    By tetreama in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-09-2012, 08:28 PM
  3. Replies: 3
    Last Post: 05-15-2012, 04:13 PM
  4. Replies: 1
    Last Post: 03-05-2012, 06:20 PM
  5. Replies: 2
    Last Post: 11-02-2007, 12:03 PM

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