+ Reply to Thread
Results 1 to 13 of 13

Count If macro

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Count If macro

    In the cells in range B2:GJJ32 I want to search for the word "TEST". If found, I want to look at the cell directly to the right of where it is found. This will always be a number ranging from 0 to 10. I want to find all instances of the word "TEST" and SUM all the values that are found directly to the right.

    Possible?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 05-16-2016 at 10:26 AM. Reason: Details
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count If macro

    Try the attached.
    Please change my columns to With ActiveSheet.Columns("B:GJJ").
    It was B-J
    Attached Files Attached Files
    Last edited by AB33; 05-16-2016 at 10:17 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Count If macro

    Solved. Thanks!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    You're welcome and thanks for the rep!

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Count If macro

    Quote Originally Posted by xladept View Post
    Try this:

    Please Login or Register  to view this content.
    If I know the word I am searching for is always going to be exactly "Test" do I need the LCase(C.Value) part or how would I alter it so that it just looks for EXACTLY "Test" and no other spellings of the word. So if it finds "test" or "TEST" it'd ignore it.

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    Like this:

    Please Login or Register  to view this content.
    But more exclusive would be:

    Please Login or Register  to view this content.
    Last edited by xladept; 05-17-2016 at 11:10 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Count If macro

    It doesn't seem to work for the attached sample though. Any ideas?
    Attached Files Attached Files

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    It looks to be the wrong data - there is no field with "Test"
    Last edited by xladept; 05-17-2016 at 01:04 PM.

  10. #10
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Count If macro

    I edited the macro so it looks for a different word which is contained numerous times in the data. The macro is contained within the attachment.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    I just realized - try:

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Count If macro

    Quote Originally Posted by xladept View Post
    I just realized - try:

    Please Login or Register  to view this content.
    Hero!

    All sorted! Thanks mate!

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Count If macro

    You're welcome and thanks for the rep!

    N.B. Since we're testing the offset for error, we can't go to the ultimate column only the penultimate
    Last edited by xladept; 05-17-2016 at 01:32 PM. Reason: punctuation

+ 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. Macro count items in sheet2 and provide count in embedded label in sheet1
    By jaredmccullough in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-05-2015, 11:27 AM
  2. Run macro if count of L > Count of K
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2014, 02:04 PM
  3. count if macro
    By superchew in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-07-2014, 04:25 PM
  4. [SOLVED] Filtering macro, count number of rows and include count in last column.
    By Folshot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2012, 07:17 AM
  5. [SOLVED] Vba Count Macro
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 07-06-2011, 03:40 AM
  6. Macro: Count rows in sheet A, copy count in sheet B, paste offset in sheet A
    By Agent:Orange in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2011, 07:56 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