# How to find data on same date & add it us

• I have a list of net returns per (stock) trade. Some of the trades had more than one trade per day. I want to locate the trades by date & add the total returns per date using macros so that it automatically finds the date with multiple trades & adds them up for a net total per date.

I can't seem to get the HTML Maker Excel Add-in to work for me. So I have just gave an example below of what I am working with.
(i.e.)
07/08/03 07:00 \$62.36 \$640.00
07/10/03 06:58 \$62.08 \$300.00
07/11/03 07:42 \$62.65 \$400.00
07/14/03 06:42 \$63.50 \$180.00
07/17/03 06:56 \$61.89 \$2,860.00
07/23/03 08:48 \$64.36 \$580.00
07/24/03 06:38 \$64.96 \$960.00
07/25/03 06:40 \$65.38 (\$920.00)
07/25/03 08:28 \$65.33 \$1,820.00
07/28/03 06:56 \$66.22 \$2,480.00
07/29/03 06:36 \$68.64 (\$1,860.00)
07/29/03 07:28 \$68.37 (\$580.00)
07/29/03 10:30 \$68.45 (\$20.00)
07/30/03 06:34 \$68.90 (\$380.00)
07/30/03 09:36 \$69.95 (\$2,500.00)

(Note: some days have only 1 & other days can have as much as 5-6 per date)
(*Note: there are three columns-1.)date/time....2.)sell price....3.)net profit/loss)
I want to identify the date in the first column & then get a net total per date.

If my explanation is not clear enough let me know. Thanks in advance for any input/help.

• Rather than a macro, I suggest using a Pivot Table. It's easy to construct and keep up to date.

• Derk-
Thanks for the advice. Except I've never used a Pivot Table. I gave it a shot by selecting the date row & net profit/loss (I don't care about the second row). And then selected Data &gt; Pivot Table. It made the pivot table just fine. I tried grouping date & profit/loss together. But to no avail. I am sure I am doing it wrong.

Could someone walk me through how to group the two so that it gives me a pivot table with the net totals like Derk's.

Thanks.

• In the pivot table layout part of the Pivot Table Wizard, drag the Date/Time Tile to the Row area and the Net tile to the Data area and show the pivot table. The dates and times should run down the first column and the Nets down the second column. Then right click in the Date column and select Group and Outline&gt;Group. Select Days and then OK. That should do it.

• Derk-

I hate to be a numbskull about this. But I am with on dragging & dropping to make the pivot table (dates in row.....nets in data). But when I right click the dates column I don't get "Group and Outline&gt;Group"....I get "Group and Show Details".

I'm lost I'm not finding "group and outline"?

What am I missing?

• I don't know if this matters or not. But when the pivot table is set up the dates are in the first column like you said, and the nets are in the second column and they are all in order matched up OK. Except the first net is on top of the first date vs. to the right of it in the net column. And I can't seem to get it to the right in the net column?

• Maybe Excel changed the title in newer versions (I'm on Excel 97). "Group and Show Details" sounds like a replacement. When you select that do you get a sub menu that has Group as one of the choices? If so, that is what you want.

I suspect the first net is on top of the first date because you don't have labels in the data you selected, so Excel is taking the first entry as a label. Try adding labels and reselect your table to include the labels.

• Yes, it does have the "group" selection-but when I try it says "Cannot group that selection".

And the labels did work at the top of each column.

• I'm running Office XP.

I'll check out the tutorial. But I am puzzled to.

• Maybe I should try posting a thread asking how to get this pivot table to work?

Would it help if I emailed you an attachment of the workbook? Or would it even help, since you are using 97.

• A new thought. Are the dates and times Excel dates and times or are they a string of text? If the later, they will need to be converted to Excel date/times.

• I'm not sure? I believe they are Excel dates/times. But they were copied from a report page & pasted into Excel.

Should I email the workbook?

• Now when I drag the nets to the data area, I get no net numbers at all. All the cells read "1"?

• Probably the nets are being "counted" rather than "summed." Go back to the layout, doubleclick on the Net tile and select Sum.
To see if the date are excel dates try adding one to one of them and see if it increase by a day (or format them af numbers and see if they change).

I'm sorry you are having such a poor intro to pivot tables. They are quite useful and worth mastering, so don't give up yet.

As to e-mail, I would rather keep to the forum if possible so all can benefit from the trouble-shooting. Let's see what the next few hours bring before resorting to e-mail.

• Derk-

1.) Changing the nets to sum vs. counting corrected that problem.

2.) As far as the dates go-I did not understand "try adding one to one of them and see if it increase by a day "......but I did try formatting the cells by changing them to numbers and it did not change anything. (Note: I highlighted the first column-which is the dates-in the pivot table & right clicked &gt; format cells). Is this what you meant? If so, they did not change.

Thank you for your patience & your consideration to even stay with this problem. I very much appreciate it.

• OK. The dates are a string of text. That's why they couldn't be grouped. To convert them from text to an excel date, in a new column of your data (not the pivot table) enter the formula =DATEVALUE(A2)
to convert the A2 (adjust to the proper reference for your first date/time cell). This will also set the time to midnight. Drag the formula as needed to convert all of the date/times and then use this column in your pivot table. Since it is now all in dates at midnight, you will only need to group if you want to see weeks or months or quarters etc.

• That makes sense, but for some reason it is not recognizing "=DATEVALUE(a2)". I understand what you are saying. I put the dates in column A & typed the formula in column B. I typed =DATEVALUE(a2) in cell B2- but it gave me #VALUE!. For some reason it does not recognize it?

It's strange because I can sort by those dates.

I played around with the dates some. I found there is a space before each date. I don't know if it affects anything. I went in and used this fomula to trim & substitute "=SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A2,"(","-"),")",""))," ","")*1"
But even then it did not work.

It still gives me the same message that "cannot group that selection".

Do you think it might have something to do with the time? Is there a way to eliminate the times?

• Now I am really puzzled. Ifthere is a space before the date, then it is text. If you get the #Value with =Datevalue that suggests it's a number. With one of your dates in A2 put the formul =A2+1 in some cell and see what happens. If the date is text, you should get a #Value! error, if its an Excel date you should get a number which when formated yields a date. See example below.