Set the color of one cell based on the color of another cell

后端 未结 4 384
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 21:54

What I would like to have is:

IF   A1 in Sheet 2 is blue  
Then A1 in Sheet 1 changes to blue

I know I can get the color of A1 in Sheet 2 b

4条回答
  •  眼角桃花
    2020-12-21 22:09

    The GET.CELL function, whilst useful, comes from the old XLM macro language which was used before VBA. You may encounter restrictions using this e.g. at that time Excel used a limited number of colours (I have read somewhere around 60?).

    Alternatively, with a bit of VBA, you could experiment with the Interior Object and also the Font Object :

    Sheets("Sheet1").Range("A1").Interior.Color = vbBlue
    Sheets("Sheet1").Range("A1").Font.Color = vbYellow
        If Sheets("Sheet1").Range("A1").Interior.Color = vbBlue Then _
        Sheets("Sheet2").Range("A1").Interior.Color = vbBlue
        If Sheets("Sheet1").Range("A1").Font.Color = vbYellow Then _
        Sheets("Sheet2").Range("A1").Font.Color = vbYellow
    

    You will likely need to explore the various ways of specifying the colors to use to give you maximum control/flexibility.

提交回复
热议问题