Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel vb

ResolvedVersion 2003

David has attended:
Access Advanced course

Excel VB

I have a lot of data listed in columns. Two of these colums are 'Area' and 'Case Number'. I have created a pivot table to summarise the data whereby I now have a count of the number of case numbers broken down by area. However the count is just counting the number of rows so if the same case number is listed twice it is recorded as 2 rather than 1.

Is there anyway of counting only unique case numbers?

RE: Excel VB

Hi David

Thank you for your question.

You can do this without using VBA.

Rather than creating the pivot table from your original data, first create a data list containing only unique records, then create the pivot table from the unique records.

To create a list of unique records, select the data range that you have currently. Then go to Data - Filter - Advanced filter.

Select Copy to another location under Action, then in the Copy to box, select a blank cell that will be the first cell in your list of unique records when it appears.

Tick the Unique records only box and click OK.

Then create your pivot table from the list of unique records.

I hope this helps - I don't know any VBA and we may not be able to provide a timely response to your question on how to resolve this using VBA at the moment.

Amanda

RE: Excel VB

Thanks for the quick reply.

Sorry i think i havent really explained this very well. Basically the advanced filter will pick up the unique case numbers but it losses the area from where they are from.

For example:


Area Case Number
Gloucestershire 1234
Gloucestershire 1234
Gloucestershire 345
Dorset 678


When I use the advanced filter it will show the unique case numbers as 1234, 345 & 678 but when I put it into a pivot table it will show the count of 3 against Gloucestershire rather than what I want it to show which is:

Gloucestershire 2
Dorset 1

Regards
Dave

RE: Excel VB

Hi David

I have used the data you provided above and created the pivot table from the filtered data (attached) - it seems to give me the result you are after. Did you create the pivot table from the results of the filter, or from the original data list?

Amanda

Attached files...

adv filter and pivot.xls

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Create Charts with One keystroke

Create a graph with one click

1. Select your data.
2. Press F11.
3. You have a graph.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.