Managing global transactions often leads to frustrating payment failures due to mistyped IBANs. While standard funding sources like international grants and wire systems facilitate these transfers, seamless processing relies heavily on upfront data integrity. Implementing a robust Excel validation formula grants your finance team immediate operational efficiency by eliminating manual verification errors.
As a key stipulation, remember that IBAN structures vary by territory; for example, Germany (DE) requires exactly 22 characters, whereas the United Kingdom (GB) requires 22. Below, we provide the step-by-step logical formulas and lookup tables necessary to systematically audit your financial data.
Validating an International Bank Account Number (IBAN) in Excel is a critical task for finance professionals, accountants, and system administrators. An invalid IBAN can lead to failed transactions, processing delays, and administrative penalties. Because IBANs vary in length from country to country (ranging from 15 to 34 characters) and must satisfy a strict mathematical checksum (the MOD-97 rule), manual verification is highly prone to error.
In this comprehensive guide, we will build a robust, step-by-step Excel solution to validate any IBAN. We will cover how to clean input data, cross-reference country-specific lengths, check structural formatting, and execute the complex MOD-97 calculation directly inside Excel without relying on external APIs.
Before jumping into Excel formulas, it is important to understand what makes an IBAN valid. An IBAN is an alphanumeric string composed of three main parts:
To fully validate an IBAN in Excel, our system must perform three distinct checks:
Users often input IBANs with spaces (e.g., DE89 3704 0044 0532 0130 00) or hyphens. To prevent these characters from breaking our formulas, we must clean the string first. Assuming your raw IBAN is in cell A2, use the following formula to sanitize it:
=UPPER(SUBSTITUTE(SUBSTITUTE(A2, " ", ""), "-", ""))
This formula converts all letters to uppercase and removes both spaces and hyphens, giving us a clean, continuous string of alphanumeric characters.
Even if an IBAN passes a basic mathematical test, it is invalid if it does not match its home country's designated length. For example, a German IBAN (DE) must be exactly 22 characters, a French one (FR) must be 27, and a Belgian one (BE) must be 16.
To implement this in Excel, we use a reference table of ISO Country Codes and their respective IBAN lengths. Below is a lookup table of common country codes and their standard lengths:
| Country Code | Country Name | IBAN Length |
|---|---|---|
| AD | Andorra | 24 |
| AT | Austria | 20 |
| BE | Belgium | 16 |
| CH | Switzerland | 21 |
| DE | Germany | 22 |
| DK | Denmark | 18 |
| ES | Spain | 24 |
| FI | Finland | 18 |
| FR | France | 27 |
| GB | United Kingdom | 22 |
| GR | Greece | 27 |
| IE | Ireland | 22 |
| IT | Italy | 27 |
| LU | Luxembourg | 20 |
| NL | Netherlands | 18 |
| NO | Norway | 15 |
| PL | Poland | 28 |
| PT | Portugal | 25 |
| SE | Sweden | 24 |
If you set up this table in a separate tab named IBAN_Rules within columns A:C, you can use the following formula to verify that the length of your cleaned IBAN matches its official national standard:
=LET(
CleanIBAN, UPPER(SUBSTITUTE(SUBSTITUTE(A2, " ", ""), "-", "")),
CountryCode, LEFT(CleanIBAN, 2),
ActualLength, LEN(CleanIBAN),
ExpectedLength, XLOOKUP(CountryCode, IBAN_Rules!$A:$A, IBAN_Rules!$C:$C, 0),
IF(ExpectedLength = 0, "Invalid Country Code", IF(ActualLength = ExpectedLength, "Length OK", "Invalid Length"))
)
This LET-driven formula isolates the country code, counts the actual characters, matches them against our reference table, and outputs a clear warning if the length or country code is incorrect.
The MOD-97 checksum (governed by ISO 7064) is the ultimate test of an IBAN's authenticity. The mathematical process requires you to:
Standard Excel math functions can only handle numbers up to 15 digits of precision. Because an expanded IBAN can easily be 30 to 70 digits long, using a standard formula like =MOD(VALUE(IBAN_Number), 97) will fail, yielding a #NUM! or incorrect rounding error.
To bypass this limitation without VBA, we can utilize Excel 365's dynamic array functions (specifically REDUCE and LAMBDA) to process the large number iteratively, digit-by-digit, applying modular arithmetic properties.
If you are using Microsoft 365 or Excel 2021, you can use this state-of-the-art array formula to calculate the MOD-97 checksum of the IBAN in cell A2:
=LET(
Clean, UPPER(SUBSTITUTE(SUBSTITUTE(A2, " ", ""), "-", "")),
Rearranged, MID(Clean, 5, LEN(Clean)) & LEFT(Clean, 4),
ConvertChar, LAMBDA(char, LET(code, CODE(char), IF(AND(code >= 65, code <= 90), TEXT(code - 55, "0"), char))),
NumString, REDUCE("", MID(Rearranged, SEQUENCE(LEN(Rearranged)), 1), LAMBDA(acc, val, acc & ConvertChar(val))),
Checksum, REDUCE(0, MID(NumString, SEQUENCE(LEN(NumString)), 1), LAMBDA(rem, digit, MOD(rem * 10 + VALUE(digit), 97))),
IF(Checksum = 1, "VALID Checksum", "INVALID Checksum")
)
Clean: Sanitizes the input string.Rearranged: Shifts the first four characters to the end.ConvertChar: A helper lambda function that identifies letters (ASCII values 65–90) and converts them to their numeric values (A → 10, etc.), keeping numbers as-is.NumString: Iterates through each character in the rearranged IBAN using REDUCE and joins them into a giant string of digits.Checksum: Uses a digit-by-digit division algorithm: $(Remainder \times 10 + NextDigit) \pmod{97}$. This allows Excel to process an infinite number of digits without experiencing floating-point overflow.To make this practical for professional dashboards, we can combine our country-specific length validation and our mathematical checksum check into a single master formula. This ensures that a passing mark satisfies both structural and mathematical requirements.
=LET(
Clean, UPPER(SUBSTITUTE(SUBSTITUTE(A2, " ", ""), "-", "")),
CountryCode, LEFT(Clean, 2),
ActualLength, LEN(Clean),
ExpectedLength, XLOOKUP(CountryCode, IBAN_Rules!$A:$A, IBAN_Rules!$C:$C, 0),
IsLengthValid, IF(ExpectedLength = 0, FALSE, ActualLength = ExpectedLength),
Rearranged, MID(Clean, 5, LEN(Clean)) & LEFT(Clean, 4),
ConvertChar, LAMBDA(char, LET(code, CODE(char), IF(AND(code >= 65, code <= 90), TEXT(code - 55, "0"), char))),
NumString, REDUCE("", MID(Rearranged, SEQUENCE(LEN(Rearranged)), 1), LAMBDA(acc, val, acc & ConvertChar(val))),
Checksum, REDUCE(0, MID(NumString, SEQUENCE(LEN(NumString)), 1), LAMBDA(rem, digit, MOD(rem * 10 + VALUE(digit), 97))),
IF(NOT(IsLengthValid), "INVALID (Length/Country Error)", IF(Checksum = 1, "VALID", "INVALID (Checksum Failure)"))
)
This master formula returns VALID only when the country-specific length matches and the mathematical checksum is successful. Otherwise, it points out the exact reason for the failure.
If your team uses older versions of Excel (such as Excel 2013, 2016, or 2019) that do not support dynamic array functions like LET, REDUCE, or XLOOKUP, you can easily implement this validation using a User-Defined Function (UDF) in VBA.
To add this macro to your workbook:
ALT + F11 to open the VBA Editor.Insert > Module.Function ValidateIBAN_VBA(ByVal IBAN As String) As String
Dim CleanIBAN As String, Rearranged As String
Dim i As Integer, char As String, numStr As String
Dim remainder As Integer
' Step 1: Clean input
CleanIBAN = Replace(Replace(UCase(IBAN), " ", ""), "-", "")
' Step 2: Check standard minimum and maximum lengths
If Len(CleanIBAN) < 15 Or Len(CleanIBAN) > 34 Then
ValidateIBAN_VBA = "INVALID (Length Range)"
Exit Function
End If
' Step 3: Rearrange
Rearranged = Mid(CleanIBAN, 5) & Left(CleanIBAN, 4)
' Step 4: Convert characters to numbers
numStr = ""
For i = 1 To Len(Rearranged)
char = Mid(Rearranged, i, 1)
If IsNumeric(char) Then
numStr = numStr & char
Else
numStr = numStr & (Asc(char) - 55)
End If
Next i
' Step 5: Large Number Modulo 97 calculation
remainder = 0
For i = 1 To Len(numStr)
remainder = (remainder * 10 + Val(Mid(numStr, i, 1))) Mod 97
Next i
' Step 6: Return validation result
If remainder = 1 Then
ValidateIBAN_VBA = "VALID"
Else
ValidateIBAN_VBA = "INVALID (Checksum)"
End If
End Function
Once you close the VBA window, you can use this validation function directly in your spreadsheets like any regular formula:
=ValidateIBAN_VBA(A2)
IBAN_Rules country reference table up to date. While changes to IBAN structural lengths are rare, newly participating countries are periodically added to the SWIFT registry.By implementing these robust formula blocks or VBA solutions, you can guarantee data integrity, optimize your financial reporting workflows, and reduce payment transaction error rates to zero.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.