Consulting

Results 1 to 5 of 5

Thread: Help Writing Code That is Conditional on Shading of Cell

  1. #1
    VBAX Regular
    Joined
    Dec 2012
    Posts
    35
    Location

    Question Help Writing Code That is Conditional on Shading of Cell

    Hi everyone,
    I was hoping there was a formula that would enable me to do what I want, but it seems like I'll have to use VBA.

    Goal: If cell is shaded grey, take no action, if cell is not shaded, then concatenate columns C + B and do a vlookup.

    I've looked through the forum but couldn't find what I needed. Any help would be greatly appreciate!

    Thanks guys!!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    If cell is shaded grey,
    There are lots of gray shades, and many look alike, but might be slightly different. How did the cell get gray?


    Can you post a small sanitized example workbook?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Dec 2012
    Posts
    35
    Location
    Quote Originally Posted by Paul_Hossler View Post
    There are lots of gray shades, and many look alike, but might be slightly different. How did the cell get gray?


    Can you post a small sanitized example workbook?
    Sure! Cells are greyed out by another party working in the same spreadsheet. If cell is grey, then the cell contents should be zero. Everything else needs to be updated via vlookup.

    Sample_VBAExpress.xlsm

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    What's the vlookup logic nd do you really want to VLookup 1000 & Marine?

    Instead of testing for .ColorIndex = 15 (Gray in your sample WB) to ignore, could you test for xlColorIndexNone and process them i.e. the uncolored ones? Since there could be many shades of Gray, it might be safer
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Regular
    Joined
    Dec 2012
    Posts
    35
    Location
    Quote Originally Posted by Paul_Hossler View Post
    What's the vlookup logic nd do you really want to VLookup 1000 & Marine?

    Instead of testing for .ColorIndex = 15 (Gray in your sample WB) to ignore, could you test for xlColorIndexNone and process them i.e. the uncolored ones? Since there could be many shades of Gray, it might be safer
    I should've been clearer. I plan to concatenate the product & year (e.i. Marine1998, Marine 1999, ....) to create a unique key and then use that to lookup a specific column in another sheet.

    REVISION TO ORIGINAL THOUGHT: Instead of referencing the color, I'll use the same logic above to lookup and identify whether a value (in the other sheet) is less than 0.1. I'll use that to determine whether to input a zero or not rather than referencing the cell color.

Posting Permissions

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