Solved

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

Posted on 2010-11-27
5
1,189 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
  • 3
5 Comments
 
LVL 39

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Calculate Average - Grouped Values 7 23
Excel VBA 4 27
Excel - DATEDIF error #NUM 6 26
VBA to add shapes inside a chart 9 20
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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