?
Solved

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

Posted on 2010-11-27
5
Medium Priority
?
1,252 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

752 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