Calculate No. of Objects on Floor Plan

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

I would like to calculate how many books of various
dimensions (only Length and Width - not Depth) will fit
onto a given floor plan of a box.

So the input is two dimensions - Length and Width.
The ouput is the number of books that will fit on the
floor plan with no overlaping.

does anyone know how to go about starting this?

Many Thanks,


Simon
 
Simon

Try this

Function BooksInBox(L As Long, W As Long) As Long

Dim BoxL As Long 'always >=BoxW
Dim BoxW As Long 'always <=BoxL
Dim NumBooks As Long, NumBooks2 As Long
Dim RemBox As Long


BoxL = 50
BoxW = 40

'Test lenghtwise
NumBooks = (BoxL \ L) * (BoxW \ W)
RemBox = BoxL - ((BoxL \ L) * L)
NumBooks = NumBooks + ((RemBox \ W) * (BoxW \ L))

'Test widthwise
NumBooks2 = (BoxL \ W) * (BoxW \ L)
RemBox = BoxL - ((BoxL \ W) * W)
NumBooks2 = NumBooks2 + ((RemBox \ L) * (BoxW \ L))

BooksInBox = Application.Max(NumBooks, NumBooks2)

End Function
 
Back
Top