2

I cannot get conditional formatting to copy to the right (with paint brush) because excel references the wrong cells when copied. This is what I need to achieve:

A1 needs to be formatted if Sheet2!E4=empty I have conditional formatting formula set as "=isblank(Sheet2!E4)=false" and it works.

Now I need to achieve the exact same formatting for the following scenarios:

A1 needs to be formatted if Sheet2!E4=empty

B1 needs to be formatted if Sheet2!E5=empty

C1 needs to be formatted if Sheet2!E6=empty, etc.

Notice that I'm trying to make excel copy the conditional formatting formula left to the right (columns A-C) but the reference cells are going top to bottom (rows 4-6).

Is there any way to achieve this without having to type the conditional formatting formulas individually? Maybe something with offset included? It's a very large table and I'd never be done. Any input is appreciated!

2
  • Have you considered using absolute references (e.g. Sheet2!$E$4)? Or am I missing something?
    – BillDOe
    Commented May 2, 2019 at 23:10
  • 1
    You could use INDIRECT to build the cell references, converting references to the current column number into row numbers. Another approach would be to use OFFSET to reference the desired cell relative to an anchor sell. Calculate the row offset based on column numbers.
    – fixer1234
    Commented May 3, 2019 at 4:09

2 Answers 2

1

One way this can be accomplished using setting up a helper row in any of the sheets.

In the below example I have added a helper row in a new sheet - Sheet3, as below. Using this you are essentially transposing to get a reference to the cells in Sheet2 which you would like to use in your conditional formatting on Sheet1. enter image description here

Next, setup the below conditional formatting formula of cell A1 in Sheet1. =INDIRECT(CONCATENATE("Sheet2!"&Sheet3!A1))=""

In the formula above, the INDIRECT function will help to translate Sheet3!A1 to the contents of A1 which then becomes Sheet2!E4 and evaluate it against a blank value.

Now you can copy formats from A1 to the range of cells across. As you copy across, the normal excel behavior kicks in and replaces A1 to A2, A3, A4 and so on in the subsequent cells. HTH

2
  • Interesting variation. But, as soon as you realize that the values in Sheet3 can be written as "E"&(COLUMN()+3), you realize that you don’t need to have Sheet3 at all. Also, you don’t need to say CONCATENATE(x&y) — it’s like saying SUM(x+y). Just say x&y for concatenation and x+y for addition. Commented May 3, 2019 at 16:37
  • Thanks @Scott, great inputs as always. I'll update my answer a bit later Commented May 4, 2019 at 1:05
1

Option 1

Another way that is similar to Bharat's answer is to make the reference absolute but offset with an an index row that increments by +1 per column.

For a visual, lets say that we have the following in Sheet1:

E3  Data Header [not actual data, just the header]
E4  Apple
E5  Banana
E6  Orange
E7+ [Blank]

This is what you could do with sheet2, you can add a row (make it invisible if you want), start with 1 and increase by 1 per column. Starting with the left most column, put your offset formula in an IF statement and reference the index column. This is where you want to stop dragging/copying from to the right on sheet2, as you drag right, the offset will increase by +1 as your reference increases.

Maybe it's easier to see visually. Below is a visual of Sheet2, I also revealed the data returned so you know the offset is working, and a sample of an embedded offset function in an IF(ISBLANK,TRUE,FALSE) Excel formula. As you can see the system will increment the offset column, but not the reference column, this way with your index, it's increasing down on sheet 1, while moving across on sheet 2.

[Sheet2] https://i.sstatic.net/OZKE3.jpg


Option 2

Offset based on the column, you don't need to even create an index row to reference, if you aren't starting from A1, you may need to adjust the column offset accordingly. This also may not work well in all situations.

From Sheet1

=IF(ISBLANK(OFFSET(Sheet2!$E$3,COLUMN(),0)),TRUE,FALSE)
4
  • (1) I don’t understand your Option 1.  (2) Your Option 2 looks pretty good, but you seem to be off by one (i.e., A1 should be looking at Sheet2!E4, not Sheet1!E3).  (3) The ISxxxxxx functions return Boolean values.  IF(Boolean,TRUE,FALSE) is redundant; just use the Boolean value. Commented May 3, 2019 at 6:26
  • It's just an example, if starting from A1 it should probably like so: =IF(ISBLANK(OFFSET(Sheet1!$E$3,COLUMN(),0)),TRUE,FALSE) If E3 is the header and we want the row below that, then the offset of E3 +1 will equal E4 returned.
    – Ron L
    Commented May 3, 2019 at 7:09
  • Right; my point is that you say COLUMN()-1, and, with the -1, it’s wrong.  I see that you improved the formula in your comment (dropping the -1), but you haven’t fixed your answer.  Also, even in your corrected comment, you are still saying IF(...,TRUE,FALSE) and you are still testing the value in Sheet1. Commented May 3, 2019 at 16:23
  • Fixed, the COLUMN()-1 is if you don't start from A1 and the OP can simply switch the sheets, I'll update the answer to be specific to his/her scenario.
    – Ron L
    Commented May 3, 2019 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .