Conditional Formatting - Refer to different row depending on whether row number is odd or even.

Herakles

Well-known Member
Joined
Jul 5, 2020
Messages
927
Office Version
  1. 365
Platform
  1. Windows
I want to be able to refer to a cell in the same row if the formatted cell is in an odd row and to the row above if the formatted cell is in an even row.

How do i do this?

Thanks.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Take a look at the ISODD and ISEVEN functions.

You can use these on the ROW() function, which returns the row number of the row the formula is placed in, i.e.
Excel Formula:
=ISEVEN(ROW())
 
Upvote 0
Take a look at the ISODD and ISEVEN functions.

You can use these on the ROW() function, which returns the row number of the row the formula is placed in, i.e.
Excel Formula:
=ISEVEN(ROW())
I've got that bit to work but how do I refer to a cell in the row above only on the even rows?

I really need a non volitile version of Offset.
 
Upvote 0
It would be very helpful if instead of speaking in vague generalities, if you actually give us an example of exactly what it is you are trying to do.
Then we may be able to build a solution tailored to your specific situation, instead of just vague responses to vague questions.

And please explain what exactly you mean here:
I really need a non volitile version of Offset.
and why it needs to behave that way.
 
Upvote 0
Go to Home -> Conditional Formatting -> Highlight Cells Rules -> More Rules or New Rules
and Select the last option, i.e. “Use a formula to determine which cells to format”
Inter below formula in (Edit the Rule Description)
“=ISEVEN(ROW())”

Click on the "Format" button to choose the format that you want to apply to the even rows. Select Your Range, I did it only for $A$1:$I$20.
Repeat
Note: Posted the answer based on public interest and pure good faith.
 
Upvote 0
It would be very helpful if instead of speaking in vague generalities, if you actually give us an example of exactly what it is you are trying to do.
Then we may be able to build a solution tailored to your specific situation, instead of just vague responses to vague questions.

And please explain what exactly you mean here:

and why it needs to behave that way.
Please see the image.

I want the formulas in the CF that applies to the range F3:K12 to refer to the red cells on the same row if an odd row and on the row above if it is an even row.

Thanks
 

Attachments

  • ExcelGrid.JPG
    ExcelGrid.JPG
    83 KB · Views: 2
Upvote 0
Please the Conditional Formatting formulas, so we can help you update it accordingly.
We can not update a formula if we don't know what it is.
 
Upvote 0
Please the Conditional Formatting formulas, so we can help you update it accordingly.
We can not update a formula if we don't know what it is.
Odd rows : =IF(ISODD(ROW()),IF($M3=1,TRUE,FALSE),FALSE)

Even rows : =IF(ISEVEN(ROW()),IF($M3=1,TRUE,FALSE),FALSE)

I need to adjust these.

I'm just trying to understand the method and then I can apply it to a more complicated model.

Thanks
 
Upvote 0
Something like:
Rich (BB code):
=IF(ISODD(ROW()),AND($M3=1,...),AND($M2=1,...))

Because a row number can only ever be EVEN or ODD, you only need to check one condition. If it is not one, it is the other.
AND and OR functions return boolean values, by definitition, so you don't explicitly need to tell them to return TRUE or FALSE.

The Red part of the function is what to do on an ODD number row, and blue is for the EVEN number row.
 
Upvote 0
Something like:
Rich (BB code):
=IF(ISODD(ROW()),AND($M3=1,...),AND($M2=1,...))

Because a row number can only ever be EVEN or ODD, you only need to check one condition. If it is not one, it is the other.
AND and OR functions return boolean values, by definitition, so you don't explicitly need to tell them to return TRUE or FALSE.

The Red part of the function is what to do on an ODD number row, and blue is for the EVEN number row.
Where the row is EVEN I need to refer to the row above in the formula and if ODD I need to refer
to the same row. How do I do that?
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,079
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top