View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default help needed with macro

sort your data by UIC so the the
Date out is followed by the
Date in lines.

assume the first entry is in row 2 and the date for the row is in column D,
UIC code in Column A

In column E for example, put in a formula like this

=if(A2=A3,D3-D2,if(A2<A1,"Not Returned",""))

then drag fill this down the column.

Adjust D3-D2 to reflect the number of days - if the start date is counted,
D3-D2+1 for example.

you can then apply an autofilter (Data=Filter=Autofilter) and in column E
select the dropdown, select custom and set the conditions does not equal
"Not Returned" and does not equal "". This will just show the returned
items (row showing when they went out) with the number of days they were
out. You can select the data and copy and paste (edit=Paste Special =
Values) to another sheet. Only the visible rows will be copied.

--
Regards,
Tom Ogilvy


"Lorraine" wrote in message
...
Hi

I am trying to create a macro for a report that gets
generated regularly from an asset tracking program. It
returns a list with a column for UIC code, a column for
location issued from and one for location issued to plus
a date issued column. So you might have one item issued
out from A to B, then the same item returned from B to A
on a different line. Here's the dilemma, for accounting
purposes I need to track how many days each item was out;
not sure how to do this when it would have to refer to 2
different lines and the second problem is that some items
only went out and didn't come back and so if I sort by
uic, I get two lines for most items but one line for a
few, it also has to track those items that only went out
and didn't come back . Not sure if this is possible but
would sure appreciate any assistance.