# Gap fills and cross joins in Excel

The cross join problem is similar - we have two sets of values and need to enumerate each combination. The key point is realizing that we know what the values should be in a particular row and deriving the formula to get those values. My approach uses integer division to get the value in the first column and modulo to get the value in the second column although any function that’s deterministic should work. In the image below, the formula in cells D2 through D25 is =INDEX($A$2:$A$5,(ROW()-2)/$H$2+1) and the formula in cells E2 through E25 is =INDEX($B$2:$B$7,MOD(ROW()-2,$H$2)+1).