This sound to me very similar to a shipping logic problem. The below is defiantly not the answer but it is a start.
Dim shapeArray(3, 2) As Integer
Dim containerWidth As Integer = 11
Dim containerHeight As Integer = 7
shapeArray(0, 0) = 5
shapeArray(0, 1) = 5
shapeArray(1, 0) = 2
shapeArray(1, 1) = 5
shapeArray(2, 0) = 1
shapeArray(2, 1) = 1
shapeArray(3, 0) = 5
shapeArray(3, 1) = 6
Dim totalArea As Integer = 0
For i As Integer = 0 To UBound(shapeArray)
totalArea += (shapeArray(i, 0) \* shapeArray(i, 1))
Next
If totalArea > (containerWidth \* containerHeight) Then
MsgBox("Shapes are unable to fit into container")
Exit Sub
End If
The above code basically checks to see if all the shapes will fit into the container/main box. You will perhaps need to sort the array into longest sides, then position the largest sized shapes into the box first. Also take into consideration that some of the shapes could potentially be rotated. Might be worth looking into logic/calculations for packing boxes as well as games development, Id be very interested to know if you find some good samples. Hope this helps.