Arlen Beiler
Arlen Beiler

Reputation: 15876

Setting a range to "False" and changing the color of cells based on value

I have an old Excel application that someone made, and I am wondering what this does:

Range("AF6") = "FALSE"

Edit: I discovered that it sets the cell to False. This changes the color of another cell, how does it do that?

Upvotes: 1

Views: 900

Answers (2)

Saladin Akara
Saladin Akara

Reputation: 2548

The other cell will have a condition along the lines of (in pseudocode):

if (Range(AF6) = "FALSE") then
    thisCell.Background = colour
endif

Been a while since I've done VBA, so not sure of the exact syntax, but that is essentially what will be happening. Might be worth finding out the 'business' logic for the cell's colour changing - will help to clarify it for you.

Upvotes: 1

Phil.Wheeler
Phil.Wheeler

Reputation: 16848

This is VBA short-form for setting the value of a range of cells (or in this case, a single cell). So the example you've provided will actually insert the text value "FALSE" into cell AF6.

If the colour of the other cell is not being set in code, then I would suggest it was done through conditional formatting.

Upvotes: 3

Related Questions