+ Reply to Thread
Results 1 to 2 of 2

Help with VB code to fine repeated values and produce a report

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with VB code to fine repeated values and produce a report

    Hi All

    I was hoping someone can can help with the following problem. Unfortunately I can not attach a sample file as for some reason the attachment button hasn't been working for me for a while.

    I have included a sample below:
    Customer No Expenditure Dept Date
    123 120 Mens Mon
    123 130 Sport Mon
    456 140 Food Mon
    789 150 Mens Tue
    789 111 Children Tues
    111 112 Food Wed
    222 454 food Wed
    222 574 Sport Wed
    222 43 Children Wed
    789 253 Children Thu

    Table above shows the customers who have shopped in the store on certain day in one week. I need help with the code to do the following:
    Look at customers and see whether a customer has bought from two different departments in one day (i.e. customer 123 but not customer 111). If they have bought an item from two different departments in one day then see if one of the departments was Mens. If it was men the give me the total expenditure for each department, i.e. for customer 123 list totals the expenditure for each of the department , Mens =120 , sport 130. But if they have shopped more than once in one day but haven't shopped in Mens then do not include them in the report. In the above table for example customer 789 will be reported for their shopping on Tuesday and not for Thursday as they only shopped once on thursday and on Tuesday one of the departments was Mens. But we will not report customer 222 because although they shopped in more than one department in one day, Mens wasn't one of the departments.

    In my actual file I have over three thousand lines and I am trying to analyse the spending habits of customers who buy from Mens as where are they likely to shop next.

    Thanks for your help in advance
    I hope my example is clear

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,883

    Re: Help with VB code to fine repeated values and produce a report

    No VBA, I couldn't muster up the energy. I did however make a formula solution using 2 dozen helpers or so, one being array formula.

    A piece of VBA code can be written of course but I reckon my formulas can be greatly improved upon.
    I also think some PivotTable wizard here on the forum can solve it in a much neater way.
    Attached Files Attached Files
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 04-17-2016, 07:34 PM
  2. [SOLVED] the code is finding repeated values but i need to search values from E column to D
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2014, 01:33 AM
  3. Replies: 1
    Last Post: 10-11-2014, 04:52 AM
  4. [SOLVED] VBA code to search for #REF, #VALUE, #N/A within multiple excel sheets and produce report
    By nadiar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-02-2013, 01:56 PM
  5. Replies: 12
    Last Post: 01-01-2013, 02:54 AM
  6. [SOLVED] Append data to repeated values with a fixed array to be repeated on value change
    By anchuri_chaitanya in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2011, 12:30 AM
  7. VB Code to sum repeated values?
    By chandrmh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2007, 03:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1