+ Reply to Thread
Results 1 to 7 of 7

overide conditional formatting with VBA

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Wink overide conditional formatting with VBA

    I have a macro that checks a barcode to see if it a valid barcode. if it isn't it makes the cell red to show there is an error. this all works great except that I use conditional formatting to color band every second row to make the data stand out because there is over 3000 lines in the spreadsheet. my problem is that while the if an error occurs where there is no color it is fine but if there is color it hides the error color so the error doesn't show. is there a way around the conditional formatting either by doing the color banding with VBA or to makeconditional formatting's priority lower. any help would be much appreciated. i've included the code i use below.

    Thanks in advance,

    Chris

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: overide conditional formatting with VBA

    You could create a simple UDF to return true for a valid barcode based on length and checksum, and add that to the existing conditional formatting.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: overide conditional formatting with VBA

    I'm pretty new to VBA, so how would i do that?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: overide conditional formatting with VBA

    Change the code in the sheet module to this:
    Please Login or Register  to view this content.
    Then put this in a code module:
    Please Login or Register  to view this content.
    Then select A1 on Sheet1 and do Insert > Name > Define

    Sheet1!Me Refers to:=A1

    frmChkBad Refers to: =NOT(IsValidChecksum(Sheet1!Me))

    Then select the relevant portions of columns L/M/N, and do Format > Conditional Formatting,

    Formula is =frmChkBad and format as red

    You can integrate the color banding after you get all that straight.

  5. #5
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: overide conditional formatting with VBA

    I'm having issues with:

    Then select A1 on Sheet1 and do Insert > Name > Define

    Sheet1!Me Refers to:=A1

    frmChkBad Refers to: =NOT(IsValidChecksum(Sheet1!Me))

    Then select the relevant portions of columns L/M/N, and do Format > Conditional Formatting,

    Formula is =frmChkBad and format as red

    i'm using Office 2007 so i went formulas>defined names> define names but it giving me an error when i try to put in it says it's not a valid name. what am i doing wrong

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: overide conditional formatting with VBA


  7. #7
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: overide conditional formatting with VBA

    Still can't get it to work. and i get a database error trying to upload the file

+ 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