Formatting Issues

Fix Excel Conditional Formatting Borders for a Dynamic Range

Bushra ParveenBushra Parveen Nov 12, 2026 870 views

Question details

Apply borders through conditional formatting across columns C through I only when the corresponding cell in column B contains a value.

Fix Excel Conditional Formatting Borders for a Dynamic Range
Product
Microsoft Excel
Device & OS
not provided
Scenario
The worksheet has a row-based range that can grow or shrink, and formatting must evaluate each row independently.
Observed behavior
Borders should appear in C:I for each populated row in column B and disappear for rows where column B is blank.
Before you start

Identify the first row of your data before creating the rule; the row number in the formula must match that first selected row. Select the entire anticipated formatting area, such as C7:I1000, so new entries receive the rule automatically.

Solution 1Recommended

Create a formula-based conditional formatting rule for the full range

Use this method to apply the same border format across C:I whenever the matching cell in column B is not empty.

The formula uses an absolute column reference ($B) so every cell checks column B, while the relative row number changes for each row in the selected range.

1
Select the target cells

Select the complete range that should receive borders, for example C7:I1000. Start the selection on the same row as your first data row.

2
Open a new conditional formatting rule

In Excel, go to Home > Conditional Formatting > New Rule, then choose Use a formula to determine which cells to format.

3
Enter the mixed-reference formula

In the rule formula box, enter =$B7<>"". Replace 7 with the first row number of your selected range if your data begins on a different row.

4
Set the border style

Select Format > Border, choose the required border sides and line style, then select OK.

5
Confirm the applied range

Select OK to save the rule, then open Home > Conditional Formatting > Manage Rules and verify that Applies to is set to =$C$7:$I$1000 or your intended target range.

Create a formula-based conditional formatting rule for the full range
Why the rule works: The $B portion locks the check to column B, while the row number remains relative. As Excel evaluates each row, B7 becomes B8, B9, and so on.
WPS Spreadsheets formatting tools

Apply Dynamic Conditional Formatting Borders in WPS Spreadsheets

WPS Spreadsheets lets you create formula-based conditional formatting rules that add borders to a selected range when a related column contains data. Use the same mixed-reference formula to keep row-based borders accurate as your list grows.

  1. 1. Select the destination range: In WPS Spreadsheets, select the cells to format, such as C7:I1000.
  2. 2. Open conditional formatting: Go to Home > Conditional Formatting and choose New Rule.
  3. 3. Choose a formula rule: Select the option to use a formula for determining which cells to format.
  4. 4. Enter the row-based condition: Type =$B7<>"" in the formula field, using the first row number of your selected range.
  5. 5. Apply borders and save: Choose Format > Border, set the border style, and confirm the rule to apply it to the selected range.
Apply borders across C:I based on whether the corresponding column B cell contains a value.Use mixed cell references to evaluate each row correctly.Open and edit Microsoft Excel .xlsx and .xls spreadsheets with compatible formatting support.Use a lightweight, familiar spreadsheet interface for managing conditional formatting rules.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the formula use $B7 instead of B7?

$B7 locks the column to B while leaving the row relative. This makes every cell in C:I check column B on its own row, such as B7, B8, and B9.

Should the formula row number match the first row in the selected range?

Yes. If the Applies to range begins at C7, use =$B7<>"". If it begins at C10, use =$B10<>"" so the rule is aligned with the target range.

How do I extend conditional formatting borders to future rows?

Open Home > Conditional Formatting > Manage Rules and expand the Applies to range, for example from =$C$7:$I$100 to =$C$7:$I$1000. Rows with blank column B cells will remain unformatted.

Why are borders appearing when column B looks blank?

A cell may contain a formula returning an empty string, spaces, or invisible characters. Check the cell contents and remove spaces if needed; a formula returning "" can require a different test depending on the intended behavior.