# Calculate a ratio from two numbers in Excel

To generate the ratio of two numbers to each other (e.g. 4:3, 16:9, etc.), you can do using division, the GCD function, and concatenation. In the formula of the formula below num1 represents the first number (the antecedent) and num2 represents the second number (the consequent).

## Formula

=num1/GCD(num1,num2)&":"&num2/GCD(num1,num2)

## Explanation

In the example, the active cell contains this formula:

=B4/GCD(B4,C4)&":"&C4/GCD(B4,C4)

Note: the GCD function only works with integers.

### How this formula works

This formula looks complicated, but, at the core, it is quite simple, and created in two parts like so:

= (formula for number1) &":"& (formula for number2)

On the left, the GCD function is used to calculated the **greatest common divisor (GCD)** of the two numbers. Then the first number is divided by the GCD. On the right, the same operations are performed with the second number.

Next, the result of the right and left operations are joined together using concatenation, with the colon (“:”) as a separator. So, altogether, we have:

=B4/(GCD(B4,C4)) &":"& C4/GCD(B4,C4) =1280/(GCD(1280,720)) &":"& 720/GCD(1280,720) =1280/80 &":"& 720/80 =16 &":"& 9 =16:9

Note that the final result of this formula is a text value.