+ Reply to Thread
Results 1 to 8 of 8

Counting if two cell match saved value(i need my working code revised)

  1. #1
    Registered User
    Join Date
    05-21-2017
    Location
    austin,tx
    MS-Off Ver
    2016
    Posts
    8

    Counting if two cell match saved value(i need my working code revised)

    Hello i spent the time to create my own working code however its not as efficient as i would like.
    Any advice, even if you only make 1 or 2 lines better, please post.

    for what this code does - grabs the cell values of column B(product) and C(Brand) with current row number, then starts a loop for any matches where both column B(product) and C(Brand) are the same and the saved value.
    Then and adds to total count AND also counts the value in column F(Price) for our end result.

    Anyway this is a project for work and the actual values im trying to sort by from a database pull... there are many different actual values in column B/C however i cant post anything related to it, so i made this sample excel file.
    Attached Files Attached Files
    Last edited by fullerorb7; 06-26-2017 at 09:29 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Counting if two cell match saved value(i need my working code revised)

    Have you considered making a Pivot Table? It seems that your data is well suited for it.

    If you do a internet search for something like Excel Pivot Table tutorial, you'll find several videos and step-by-step guides.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Counting if two cell match saved value(i need my working code revised)

    My 2 cents.
    Push CommandButton for results.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Registered User
    Join Date
    05-21-2017
    Location
    austin,tx
    MS-Off Ver
    2016
    Posts
    8

    Re: Counting if two cell match saved value(i need my working code revised)

    Quote Originally Posted by AlphaFrog View Post
    Have you considered making a Pivot Table? It seems that your data is well suited for it.

    If you do a internet search for something like Excel Pivot Table tutorial, you'll find several videos and step-by-step guides.
    i watched an video on pivot tables and ummmm..... you made the lightbulb in my head blink a few times, i will definitely research into these, this will be a ridiculously huge and efficient future upgrade to my tool.

    but... for now i spent the past month on this(much much more code than what i posted) and basically almost done, except for the part that my tool takes 60-90 seconds to process all the code i wrote, also what i posted plays a huge role in other columns it populates.

    next week i will research pivot tables for sure, but for now basically all my code has been written and i just need to work on code efficiency to get it to at least 20-30 seconds, then i will lookin to pivots.

  5. #5
    Registered User
    Join Date
    05-21-2017
    Location
    austin,tx
    MS-Off Ver
    2016
    Posts
    8

    Re: Counting if two cell match saved value(i need my working code revised)

    Quote Originally Posted by bakerman2 View Post
    My 2 cents.
    Push CommandButton for results.
    Wow i got two experts attacking me with crazy good info... any way you could get the result to be placed in column D next to the product/brand on each row?
    thanks for you help

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Counting if two cell match saved value(i need my working code revised)

    Both files have same code, only number of rows is different. (H3 in second file)
    Msgbox gives you time passed to process entire range.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by bakerman2; 06-27-2017 at 07:32 AM. Reason: Added code

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Counting if two cell match saved value(i need my working code revised)

    Quote Originally Posted by fullerorb7 View Post
    grabs the cell values of column B(product) and C(Brand) with current row number, then starts a loop for any matches where both column B(product) and C(Brand) are the same and the saved value.
    Then and adds to total count AND also counts the value in column F(Price) for our end result.
    .
    try
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Counting if two cell match saved value(i need my working code revised)

    This will make a Pivot Table

    Please Login or Register  to view this content.

+ 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. code to take last saved workbook and hypelink it to selected cell
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2014, 02:13 AM
  2. [SOLVED] How to revised macro code to repeat the recorded task without recording several times?
    By reimar_rem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2013, 01:34 AM
  3. [SOLVED] Marked as Final that CANNOT be revised unless saved as a new file
    By cheddarthief in forum Excel General
    Replies: 2
    Last Post: 11-09-2012, 12:45 PM
  4. [SOLVED] Match Copy & Paste Between 2 Wkbks Revised
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2011, 06:12 AM
  5. Code to check and match not working
    By endoskeleton in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2011, 03:59 PM
  6. second (revised) formula for cell content
    By nigelog in forum Excel General
    Replies: 4
    Last Post: 01-31-2011, 10:40 AM
  7. [SOLVED] Find a Cell Value (Revised)
    By Gabe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2006, 12:50 AM
  8. Format excel to revised date automatically when revised
    By annetteberrios in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-02-2005, 10:05 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