• xlColorIndexNone (Excel2003)

    Author
    Topic
    #431957

    Why does the following line colour the cell light blue when it should take away any existing colour?

    Selection.Interior.Color = xlColorIndexNone

    I’m obviously doing something wrong.

    Also, why doesn’t Excel give me help in writing code like Access; it would be nice if the VBA editor gave lists of acceptable syntax and autocompletion. I’m fresh to Excel VBA but competent in Access VBA.

    David

    Viewing 0 reply threads
    Author
    Replies
    • #1012220

      1) Try

      Selection.Interior.ColorIndex = xlColorIndexNone

      Interior has a property Color that can be set to an RGB color such as vbRed or RGB(128, 192, 255), and also a property ColorIndex that can be set to a value between 1 and 56 or to xlColorIndexNone or xlColorIndexAutomatic. You shouldn’t use xlColorIndexNone with the Color property.

      2) Selection is an ambiguous object: it could refer to a cell range or to a chart or to a graphic object. That’s why IntelliSense doesn’t work for it. It does work for ActiveCell, for example.

    Viewing 0 reply threads
    Reply To: xlColorIndexNone (Excel2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: