+ Reply to Thread
Results 1 to 7 of 7

Find Best Customer

  1. #1
    Registered User
    Join Date
    03-06-2009
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    51

    Find Best Customer

    Hi,

    I need to find the customer whom we sold more. below is the data that need to be used. I do not want to use any excel Function. there may be some blank cell in USD column against any customer.

    I just want to solve it by VB. Can anyone help me to write the code pls...

    Customer USD
    CAWALMART 3,512.02
    CAWALMART
    CAWALMART 223.42
    CAWALMART 1,837.44
    MONOPRIX 110.66
    CAWALMART
    PUMA 741.24
    KIABI 1,641.17
    MONOPRIX 793.44
    MONOPRIX 1,553.47
    MONOPRIX 701.57
    TESCO
    TESCO 1,828.39

    Thanks
    Tuhin
    Last edited by mshtuhin; 07-25-2010 at 10:29 PM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Find Best Customer

    mshtuhin,

    Detach/open workbook mshtuhin - EF 738765 - SDG14.xls and run macro FindMaxCustomer.
    Attached Files Attached Files
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    03-06-2009
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find Best Customer

    Hi Stan,

    You did excellent!! I salute you sir,
    but i m unable to apply this in another file. Can you please provide comments for each of your line to make me understand.


    thx
    tuhin

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Find Best Customer

    Quote Originally Posted by stanleydgromjr View Post
    mshtuhin,

    Detach/open workbook mshtuhin - EF 738765 - SDG14.xls and run macro FindMaxCustomer.
    Why to use macro when this can be done with simple formula
    Just put this formula in E2

    =MAX(M32:M36)

    And this one in D2

    =INDEX(L32:L36,MATCH(E2,M32:M36,0))

    And you'll get the same result which is much easier to understand...
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  5. #5
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Find Best Customer

    mshtuhin,

    The following is done without using an array, and should be easier to understand, and change to work on another data set.

    It uses AdvancedFilter of column A, Unique, to column D.

    It then inserts the following formula into cell E2:
    =SUMIF(A:A,D2,B:B)

    It then uses autofil in column E, to the last row of data in column D.

    It then formats E2:E6, and changes the formulae to values.

    It then sorts D2:E6, with sort key E2, decending, which puts the MAX customer and value into cell D2:E2. It then clears D3:E6.


    If you were to step thru the VBA code, you could see how the macro works.

    Detach/open mshtuhin - EF 738765 - V2 - SDG14.xls and run the updated FindMaxCustomer macro.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-06-2009
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Find Best Customer

    Hi Stan,

    u r gr8. yes i m stepping thru VBA. its really understandable.

    thanks soooo much.

    brgd
    tuhin

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Find Best Customer

    mshtuhin,

    Thanks, and you are welcome.

    Come back anytime.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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