Calculate No. of Objects on Floor Plan

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
 
D

Dick Kusleika

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top