Dynamic formatting
Question: I have a list that I keep adding rows to. How do i create a border that expands as the list expands?
Answer:
The easiest way to go is an excel defined table, you can customize how it looks easily:
Recommended articles
An Excel table allows you to easily sort, filter and sum values in a data set where values are related.
Adding more rows to your list expands the border automatically. See picture below.
How to create dynamic border
The border on top of the list is static. Here is how to create the top border:
- Select the top cells of your list
- Go to "Home" tab in excel 2007
- Press with left mouse button on the small triangle on the border button in the font window. See picture below.
- Press with left mouse button on "Top border"
The border on the sides of the list is dynamic. Here is how to create the border on the left side:
- Select the leftmost column in your list (In this example C:C)
- Press with left mouse button on "Home" tab on the ribbon
- Press with left mouse button on "Conditional formatting"
- Press with left mouse button on "New rule..."
- Press with left mouse button on "Use a formula to determine which cells to format"
- Press with left mouse button on "Format values where this formula is true" window.
- Type =OR(C1<>"",D1<>"",E1<>"",F1<>"")
- Press with left mouse button on Format button
- Press with left mouse button on "Border tab" tab
- Create a border on left side of cell
- Press with left mouse button on OK!
- Press with left mouse button on OK!
Here is how to create the left and bottom border on the left side:
- Select the leftmost column in your list (In this example C:C)
- Create a new conditional formatting formula. (See above list)
- Type =AND(OR($C1<>"",$D1<>"",$E1<>"",$F1<>""),$C2="",$D2="",$E2="",$F2="")
- Create a border on the left and down side of cell
Do the same thing for the right side (F:F) of the list using the two above examples. Obviously creating borders on the right and down side of cells.
Finally creating the border lines below the list:
- Select the middle columns in your list (In this example D:D and E:E)
- Create a new conditional formatting formula.
- Type =AND(OR($C1<>"",$D1<>"",$E1<>"",$F1<>""),$C2="",$D2="",$E2="",$F2="")
- Create a border on the down side of cell
Get excel sample file for this tutorial.
create-a-dynamic-border-using-excel-conditional-formatting.xls
(Excel 97-2003 Workbook *.xls)
Functions used in this article
OR(logical1, logical2, ...)
Checks whether any argument are TRUE and returns TRUE or FALSE. Returns FALSE only if all arguments are FALSE.
AND(logical1, logical2, ...)
Checks whether all arguments are TRUE and returns TRUE if all arguments are TRUE
Recommended reading
Built-in conditional formatting
Data Bars Color scales IconsHighlight cells rule
Highlight cells containing stringHighlight a date occuring
Highlight cells equal to
Highlight unique/duplicates
Top bottom rules
Highlight top 10 valuesHighlight top 10 % values
Highlight above average values
Basic CF formulas
Working with Conditional Formatting formulasFind numbers in close proximity to a given number
Highlight empty cells
Highlight text values
Search using CF
Highlight records – multiple criteria [OR logic]Highlight records [AND logic]
Highlight records containing text strings (AND Logic)
Highlight lookup values
Unique distinct
How to highlight unique distinct valuesHighlight unique values and unique distinct values in a cell range
Highlight unique values in a filtered Excel table
Highlight unique distinct records
Duplicates
How to highlight duplicate valuesHighlight duplicates in two columns
Highlight duplicate values in a cell range
Highlight smallest duplicate number
Highlight more than once taken course in any given day
Highlight duplicates with same date, week or month
Highlight duplicate records
Highlight duplicate columns
Highlight duplicates in a filtered Excel Table
Compare
Highlight missing values between to columnsCompare two columns and highlight values in common
Compare two lists of data: Highlight common records
Compare tables: Highlight records not in both tables
How to highlight differences in price lists
Compare two columns and highlight differences
Min max
Highlight smallest duplicate numberHow to highlight MAX and MIN value based on month
Highlight closest number
Dates
Highlight dates in a date rangeHow to highlight MAX and MIN value based on month
Highlight odd/even months
Highlight overlapping date ranges using conditional formatting
Highlight records based on overlapping date ranges and a condition
Highlight date ranges overlapping selected record [VBA]
How to highlight weekends [Conditional Formatting]
How to highlight dates based on day of week
Highlight current date
Misc
Highlight every other rowDynamic formatting
How to change cell formatting using a Drop Down list
Highlight cells based on ranges
Highlight opposite numbers
Highlight cells based on coordinates
Excel categories
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.