How to Return Cell Color and Formatting with an Excel Lookup
Question details
The user wants to perform a lookup that returns not just the cell's data value, but also its formatting attributes such as fill color, font style, and borders.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Attempting to retrieve source cell visual formatting alongside data values using functions like VLOOKUP or INDEX/MATCH.
- Observed behavior
- Standard Excel lookup formulas only extract data values, ignoring the original cell's background color, font, and other stylistic properties.
Since standard Excel formulas cannot extract cell formatting, ensure you have the Developer tab enabled to use VBA macros, and note that retrieving conditional formatting requires more complex programmatic handling.
Use a VBA User-Defined Function (UDF) to Copy Formatting
Since standard lookup formulas cannot return cell colors or fonts, you must use a custom VBA script to pull the static formatting from a reference cell.
Excel's built-in lookup functions are designed exclusively for retrieving data. To extract cell properties like background color or font size, you must write a VBA macro or User-Defined Function (UDF). Note that standard UDFs struggle to accurately return conditional formatting results and work best for static formats.
Go to File > Options > Customize Ribbon, and check the 'Developer' box in the right-hand list to enable macro tools.
Click 'Visual Basic' on the Developer tab or press Alt + F11 on your keyboard.
Right-click on your workbook name in the VBA Project pane, select 'Insert', and click 'Module'.
Write or paste a VBA script designed to read the source cell's .Interior.Color or .Font properties and apply them to the target cell based on your lookup criteria.
Return to your worksheet and type your new custom function just like a standard Excel formula, referencing the range that contains the desired color or format.

Recreate Formatting Using Conditional Formatting Rules
Instead of attempting to copy the source format directly, apply identical conditional formatting rules to your lookup destination cells.
Manage Data Lookups and Macros Effortlessly in WPS Spreadsheet
WPS Office provides a highly compatible and powerful spreadsheet tool that seamlessly handles complex lookup functions, conditional formatting, and VBA macros to help you style and manage your data exactly like Microsoft Excel.
- 1. Open Your Workbook in WPS Spreadsheet: Launch WPS Office and open the document containing your lookup data or macro-enabled file.
- 2. Apply Conditional Formatting: Navigate to the Home tab and use the Conditional Formatting feature to apply dynamic colors based on your lookup values without needing complex VBA.
- 3. Run Custom Macros: If you require exact format copying, enable macros within WPS Spreadsheet to run the same VBA custom functions used in Excel.

Frequently Asked Questions
Can standard lookup functions like VLOOKUP or XLOOKUP return a cell's background color?
No, standard lookup functions only retrieve the raw data value stored in a cell. They are not programmed to extract metadata such as background color, font color, or borders.
Why does my VBA function ignore conditional formatting?
Standard VBA properties read the cell's underlying static format. Conditional formatting applies layered formats dynamically. To read these, you must evaluate the DisplayFormat property, which standard User-Defined Functions cannot reliably return during routine worksheet recalculations.
How can I match cell colors without using VBA macros?
If you cannot or prefer not to use VBA, the best alternative is applying identical Conditional Formatting rules to both your source data and your lookup destination cells, ensuring they automatically format the same way based on the data values.




