Formatting Issues

How to Apply Conditional Formatting Based on Card Number and Date Range

Tauseeq MagsiTauseeq Magsi Nov 10, 2026 869 views

Question details

The user needs to highlight specific rows in a spreadsheet where a credit card number matches a target cell and the transaction date falls within a specified start and end date.

How to Apply Conditional Formatting Based on Card Number and Date Range
Product
Spreadsheet
Device & OS
not provided
Scenario
Highlighting transaction records matching multiple specific criteria (card number and a chronological date range) for financial tracking or reporting.
Observed behavior
Rows meeting all three conditions (matching card number, on or after the start date, and on or before the end date) need to be formatted automatically.
Before you start

Ensure your transaction data, credit card numbers, and date ranges are organized in clear columns without merged cells to allow the formatting formula to correctly reference the row data.

Solution 1Recommended

Use the AND Formula in Conditional Formatting

Apply a custom formula rule using the AND function to verify multiple conditions simultaneously across your dataset.

The AND function evaluates multiple logical tests and returns TRUE only if all conditions are met. This makes it perfect for verifying string matches (like a credit card number) and numeric ranges (like dates) at the same time in Conditional Formatting.

1
Select the Data Range

Highlight the entire dataset you want to apply the formatting to (e.g., A3:Z100). Do not include the header row to prevent it from being accidentally formatted.

2
Open Conditional Formatting

Navigate to the Home tab on the ribbon, click on 'Conditional Formatting', and select 'New Rule' from the dropdown menu.

3
Use a Formula

Choose the option 'Use a formula to determine which cells to format'. In the formula box, enter `=AND($D3=$H$2,$B3>=$I$1,$B3<=$N$1)` (assuming column B contains dates, column D contains card numbers, and row 3 is the first row of your selection).

4
Set the Format

Click the 'Format' button, choose your desired fill color or font style to highlight the matching rows, and click 'OK' to apply the rule.

Use the AND Formula in Conditional Formatting
Absolute vs. Relative References: Make sure to lock the condition cells (like $H$2, $I$1, $N$1) with dollar signs, but keep the row numbers relative (like $D3, $B3) so the formula accurately adjusts for each subsequent row in your dataset.
Efficient Data Management

Highlight Complex Data Instantly with WPS Spreadsheet

WPS Spreadsheet provides a highly intuitive interface for applying complex conditional formatting rules, making financial data tracking and analysis a breeze.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your financial or transaction dataset.
  2. 2. Select Data and Add Rule: Highlight the rows, go to the Home tab, click 'Conditional Formatting', and select 'New Rule'.
  3. 3. Enter the Formula: Select 'Use a formula to determine which cells to format', input your AND formula (e.g., `=AND($D3=$H$2,$B3>=$I$1,$B3<=$N$1)`), and define your highlighting color.
Easily build and manage multi-condition formatting formulas like the AND functionFully compatible with Microsoft Excel (.xlsx) conditional formatting rulesLightweight, fast, and completely free to use for your daily data processing tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why is the wrong row being highlighted when applying the formula?

This usually happens when the row number in your formula does not match the first row of your selected data range. Ensure that if your highlighted selection starts at row 3, the formula uses $D3 and $B3, not $D2 or $B2.

Can I highlight just one cell instead of the entire row?

Yes. To highlight just a single column (e.g., the transaction amount), simply select only that specific column's data range before applying the conditional formatting rule, instead of selecting the entire table.

How do I edit or delete this conditional formatting rule later?

Go to the Home tab, click Conditional Formatting, and select 'Manage Rules'. From there, you can select the rule applied to your worksheet to edit the formula, change the formatting style, or delete the rule entirely.