Fix Excel Conditional Formatting Borders for a Dynamic Range
Question details
Apply borders through conditional formatting across columns C through I only when the corresponding cell in column B contains a value.

- 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.
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.
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.
Select the complete range that should receive borders, for example C7:I1000. Start the selection on the same row as your first data row.
In Excel, go to Home > Conditional Formatting > New Rule, then choose Use a formula to determine which cells to format.
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.
Select Format > Border, choose the required border sides and line style, then select OK.
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.

Adjust an existing rule when borders are offset or missing
Use this method if a current conditional-formatting rule applies borders to the wrong rows or does not extend across all required columns.
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. Select the destination range: In WPS Spreadsheets, select the cells to format, such as C7:I1000.
- 2. Open conditional formatting: Go to Home > Conditional Formatting and choose New Rule.
- 3. Choose a formula rule: Select the option to use a formula for determining which cells to format.
- 4. Enter the row-based condition: Type =$B7<>"" in the formula field, using the first row number of your selected range.
- 5. Apply borders and save: Choose Format > Border, set the border style, and confirm the rule to apply it to the selected range.

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.




