none
MS Excel Cell Selection Color - highlighting using VBA

    Question

  • Say in a region of an Excel sheet you have a couple blue cells, a couple red cells, some cells with fancy conditional formatting bargraphs, and whatever. Then you ctrl-select the region. So what you see is a faint blue highlight or transparency over the entire area selected, and the preexisting blue and red and graphed cells go slightly darker/lighter. And if you change your selection or hit ESC then you goes back to seeing what you saw befaw.
    So my question is how to do that kind of highlighting myself in VBA using the sheet event selectionchange? Is it a matter of some formula that allows adding or subtracting values from the RGB of the cell interior color? I am interested in the kind of selection coloring that appears when doing multiple selections - that is, I don't care about the cell borders.

    Regards

    Brian

    Wednesday, September 01, 2010 7:45 PM

Answers

  • I don't know of any such built-in functions, but you can code a workaround. 

     

    Select some representative cells, then press Ctrl+Print Screen to get a picture of the screen. Paste in MS Paint, and use the 'Pick Color' tool t select the cell color. Go to Colors>>Edit Colors... >>Define Custom Colors to get the exact RGB values of various cells.

     

    If you compare highlighted vs. unhighlighted cells I'm sure you can figure out a pattern.

     

    Finally, to simulate that 'selection effect', modify the color of the desired range. For example:

     

    Selection.Interior.Color = RGB(intRed, intGreen, intBlue)

    Range("A1:Z256").Interior.Color = RGB(intRed, intGreen, intBlue)

     

    etc.

    Thursday, September 02, 2010 1:58 PM