PDA

View Full Version : Conditional format an indentation based upon a formula from separate cell



boweryreserv
05-14-2012, 12:12 PM
To whom it may concern,

I am trying to include a conditional format to indent a particular cell if another cell (month number) = 1, 6, 9 or 12.

Can anyone share some VB code that would help? Is this even possible?

Thanks very much.

Bob Phillips
05-14-2012, 01:34 PM
Can you elaborate upon what exactly you mean by indent a cell.

Aussiebear
05-15-2012, 03:09 AM
Right text format perhaps?

boweryreserv
05-15-2012, 06:26 AM
Thanks for replying.

I have a large report with a Table of Contents (TOC) on a particular worksheet.

I then have an IF statement that pulls in the categories into the TOC depending on what month it is. The month is a named range (single cell) on another worksheet. The named range = MonthNumber and equals 1-12. Month 1 pulls in different categories than Months 6, 9, 12 which is different than the other months.

There is a column of cells (d8:d29) on the TOC where, depending on the month, I would like to either:
a. increase indent 1 from the left one or more of these cells or
b. left justify one or more of these cells.

Ultimately, I was thinking about writing a formula using the conditional format like:

Default setting: all cells are left justified
1. IF month=x, increase indent by 1 or

Default setting: all cells start from the left and are indented 1,
2. IF month=x, left justify

Please let me know if you have any other questions. Thank you for your help.

Bob Phillips
05-15-2012, 07:47 AM
Okay,

start by selecting all the cells in D8:D29
left-justify the cells
setup CF with a formula of =MONTH(D8)=MonthNumber
click Format
select the Number tab
select Custom type
use a format of _wdd-mmm (or _wdd/mm/yyy, or whatever date format you want)