How to Apply Conditional Formatting Based on Card Number and Date Range
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.

- 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.
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.
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.
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.
Navigate to the Home tab on the ribbon, click on 'Conditional Formatting', and select 'New Rule' from the dropdown menu.
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).
Click the 'Format' button, choose your desired fill color or font style to highlight the matching rows, and click 'OK' to apply the rule.

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. Open WPS Spreadsheet: Launch WPS Office and open your financial or transaction dataset.
- 2. Select Data and Add Rule: Highlight the rows, go to the Home tab, click 'Conditional Formatting', and select 'New Rule'.
- 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.

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.




