How to Create Dynamic Lookup Formulas in Excel
How to Create Dynamic Lookup Formulas in Excel

Creating dynamic lookup formulas in Excel can be a game-changer for anyone working with large datasets. Whether you’re pulling data from Tally Accounting Software, generating conditional formatting rules across multiple worksheets, or expanding existing formulas to handle more complex conditions, this guide will walk you through the process step-by-step.
While tools like CelTools can automate many of these tasks with a single click, understanding how to build and customize your own lookup formulas gives you unparalleled flexibility. Let’s dive in!
The Challenge: Why Lookup Formulas Can Be Tricky

Lookup formulas in Excel are powerful, but they can also be tricky to get right. Here’s why:
- Complex Conditions: When you need a formula that checks multiple criteria before returning a value, things can quickly become complicated.
- Dynamic Data Sources: If your data is constantly changing or being updated from external sources (like Tally Accounting Software), static formulas won’t cut it. You’ll need dynamic solutions that adapt to new information automatically.
- Multiple Worksheets and Themes: Managing conditional formatting across multiple worksheets with different themes can be a logistical challenge, especially if you’re trying to maintain consistency in your reporting.
But don’t worry—we’ll break down each of these challenges into manageable steps. And for those who prefer automated solutions, we’ll show how CelTools can simplify the process even further.
The Step-by-Step Solution: Building Dynamic Lookup Formulas

Example 1: Exporting Data from Tally Accounting Software
Let’s say you’re exporting data from Tally and need to create dynamic lookup formulas based on the exported amounts. Here’s how:
- Set Up Your Data Table: First, import your data into Excel so that it looks something like this:
A B 1 ID Amount Type 2 001 $500 Dr 3 002 -$75 Cr 4 ...
- Create a Lookup Formula with Multiple Criteria: Use the INDEX and MATCH functions together to create dynamic lookups. Here’s an example formula that looks up amounts based on ID:
=INDEX(B:B, MATCH(A2,A:A,0))
- Add Conditional Logic for Positive/Negative Values: To handle positive and negative values dynamically, you can extend the formula with IF statements. For example:
=IF(INDEX(B:B,MATCH(A2,A:A,0))<0,"Negative", "Positive")
- Automate with CelTools (Optional): If this process becomes repetitive or complex across multiple datasets, consider using a tool like CelTools, which can automate these lookups and conditional checks for you.
Example 2: Conditional Formatting Across Multiple Worksheets
Let’s say you have seven worksheets with different themes, and you want to apply consistent conditional formatting rules across all of them:
- Define Your Rules in One Workbook: Start by creating your conditional formatting rule on one worksheet. For example:
– Select the range (e.g., A1:D20)
– Go to Home > Conditional Formatting
– Create a new rule based on cell value, e.g., “Highlight cells greater than 50” - Copy and Paste Rules: Unfortunately, Excel doesn’t allow direct copying of conditional formatting rules across workbooks. Instead:
– Select the range with your existing rule
– Copy (Ctrl+C)
– Go to each worksheet where you want this rule applied
– Right-click > Paste Special > Formats - Use CelTools for Advanced Automation: For more complex conditional formatting needs across multiple workbooks, consider using a tool like CelTools, which can handle these advanced scenarios with ease.
Example 3: Expanding Existing Formulas to Handle More Conditions
Let’s say you have a formula like this:
=IF($J2="","",ROUND(E2,0))
But now you need it to handle additional conditions (e.g., if E2 is less than 0 then return 0). Here’s how:
- Start with Your Existing Formula: Begin by writing down your current formula:
=IF($J2="","",ROUND(E2,0))
- Add Nested IF Conditions: Extend the logic to handle additional conditions. For example:
=IF( $J2="", "", IF( E2<0, "Negative Value", ROUND(E2,0) ) ) - Test and Refine: Make sure to test your formula with different inputs to ensure it behaves as expected.
The Advanced Variation: Using VBA for Dynamic Lookups
For those who want even more control, you can use Visual Basic for Applications (VBA) to create dynamic lookup formulas. Here’s a simple example:
Sub CreateDynamicLookup()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Example: Lookup value based on ID and Type in columns A & B, return from column C
For Each cell In ws.Range("D2:D" & LastRow)
If IsEmpty(cell) Then GoTo NextCell
Dim lookupID As String
lookupID = cell.Offset(0, -3).Value ' Column A (ID)
Dim lookupType As String
lookupType = cell.Offset(0, -2).Value ' Column B (Type)
Dim result As Variant
On Error Resume Next
result = Application.WorksheetFunction.Lookup(
2,
Application.WorksheetFunction.Index(Application.WorksheetFunction.Match(lookupID & "_" & lookupType, ws.Range("A:A" & LastRow), 0)),
Array(ws.Range("C:C"))
)
On Error GoTo 0
If IsError(result) Then
cell.Value = "Not Found"
Else
cell.Value = result
End If
NextCell:
Next cell
End Sub
This VBA script will dynamically look up values based on multiple criteria and return the corresponding value from column C.
Avoiding Common Mistakes with Lookup Formulas
- Incorrect Range References: Always double-check your range references to ensure they cover all necessary data points. Using structured references (e.g., named ranges) can help avoid errors.
– Tool Tip: CelTools helps prevent these mistakes by automating the lookup process. - Ignoring Data Types: Be mindful of how Excel interprets different types of values, especially when mixing text and numbers. Use functions like VALUE() to convert text representations of numbers into actual numeric values.
– Tool Tip: CelTools can handle data type conversions automatically. - Overlooking Hidden Cells: If your lookup range includes hidden cells or rows/columns that have been filtered out, Excel might not return the expected results. Always ensure your entire dataset is visible when creating lookups.
– Tool Tip: CelTools can scan and include all relevant data points automatically.
The Technical Summary: Combining Manual Skills with Specialized Tools
Creating dynamic lookup formulas in Excel requires a blend of manual techniques and specialized tools. While understanding how to build these formulas from scratch is essential, leveraging advanced tools like CelTools can significantly enhance your productivity.
The key takeaways:
- Dynamic lookup formulas are crucial for handling complex datasets and multiple criteria.
- Using INDEX, MATCH, and IF functions together allows you to create flexible lookups that adapt to changing data.
- For advanced users or frequent tasks, tools like CelTools can automate these processes with a single click, saving time and reducing errors.
–
Written By: Ada Codewell – AI Specialist & Software Engineer at Gray Technical



















