Solved

Loan Laptop Database Using Excel 2007 - Identify late laptops and persistant offenders

Posted on 2010-11-27
5
1,234 Views
Last Modified: 2012-05-10
Ive created a Loan Laptop spreadsheet in Excel that shows basically
who loaned the laptop
the from date
the to date
and if it has been returned
.

I created formula that shows clearly when an item is overdue and has not been returned but.....

Is their a way so that if an item is overdue it adds that users name to another sheet and includes the number of days over due and the number of times its has been overdue from that user.

e.g. Fred has borrowed a laptop for 7 days, its now day 10 and it hasnt been returned. He has  done this before but i cant see how many times. Id like the sheet to show that he has not returned the laptop X times to a total of X number of days. Built-PCs---Loan-Laptops.xlsx
0
Comment
Question by:Duco_IT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 40

Expert Comment

by:als315
ID: 34221690
Look to pivot table in sheet1. You will need additional fields and you fields should be filled with date values.
Built-PCs---Loan-Laptops.xlsx
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34221800
Duco_IT,

As you are not recording when a laptop is returned it is not possible to analyse whether they were early, on time or late. At the very least you need a column to record the date on which a laptop is returned.

In fact the 'Returned' column should be used for that rather than recording only whether or not it has been returned. If there's a blank in the Returned column then by implication, the laptop has not been returned. If it has been returned then a date of return is needed.

Patrick
0
 
LVL 45

Accepted Solution

by:
patrickab earned 500 total points
ID: 34222750
Duco_IT,

In the 'Returned' column in the attached file I have inserted random dates to simulate the dates the laptops were returned.

The code below, also in the attached file produces a report giving you a picture of User's returns' records. Press the button on the Report sheet to obtain the results.

Hope it helps

Patrick
Sub specialmacro()
Dim rng As Range
Dim rng2 As Range
Dim celle As Range
Dim celle2 As Range
Dim coll As New Collection
Dim i As Long
Dim xborrowed As Long
Dim xontime As Long
Dim xlate As Long
Dim dayslate As Long

With Sheets("Loan Laptops")
    Set rng = Range(.Cells(2, "B"), .Cells(.Rows.Count, "B").End(xlUp))
End With

For Each celle In rng
    If celle.Value > 0 Then
        On Error Resume Next
        coll.Add CStr(celle), CStr(celle)
    End If
Next celle

With Sheets("Report")
    .Cells.ClearContents
    For i = 1 To coll.Count
        .Cells(i + 1, "A") = coll(i)
    Next i
    .Cells(1, "A") = "User"
    .Cells(1, "B") = "Times borrowed"
    .Cells(1, "C") = "Returned on-time"
    .Cells(1, "D") = "Returned late"
    .Cells(1, "E") = "Total days late"
    .Cells(1, "F") = "Ave. days late"
    .Rows(1).Font.Bold = True
    .Columns("A:F").AutoFit
    Set rng2 = Range(.Cells(2, "A"), .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each celle2 In rng2
    For Each celle In rng
        If celle2 = celle Then
            xborrowed = xborrowed + 1
            If celle.Offset(0, 3) <= celle.Offset(0, 2) Then
                xontime = xontime + 1
            Else
                xlate = xlate + 1
                dayslate = dayslate + (celle.Offset(0, 3) - celle.Offset(0, 2))
            End If
        End If
    Next celle
    celle2.Offset(0, 1) = xborrowed
    celle2.Offset(0, 2) = xontime
    celle2.Offset(0, 3) = xlate
    celle2.Offset(0, 4) = dayslate
    celle2.Offset(0, 5) = IIf(dayslate = 0, 0, Int(dayslate / xlate))
    xborrowed = 0
    xontime = 0
    xlate = 0
    dayslate = 0
Next celle2

End Sub

Open in new window

Loan-laptops-01.xls
0
 

Author Closing Comment

by:Duco_IT
ID: 34237587
Thanks loads for that
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34260841
Duco_IT - Pleased it helped. Thanks for the grade. - Patrick
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question