+ Reply to Thread
Results 1 to 4 of 4

using a cell reference for criteria in vba countif

  1. #1
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    using a cell reference for criteria in vba countif

    excel1.png

    I have 5 cols of data that I want to count occurrences in.

    I have run a unique filter to list the ID's in a separate area.
    Now I want to count occurrence for each column and ID using VBA.

    I am attempting to use countif with the criteria being from a cells text.
    If I run

    Range("O" & i).Formula = "=countif(O15:O" & lastrow & ",n165)"

    , it works fine, but I can't get it right to run with the cell as a reference.

    Any help would be appreciated.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,043

    Re: using a cell reference for criteria in vba countif

    Try:
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    Re: using a cell reference for criteria in vba countif

    That did the job.

    Don't know why I couldn't see it myself.

    Many thanks

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,043

    Re: using a cell reference for criteria in vba countif

    You're welcome. Thanks for the rep.


    Always more obvious when you know

+ 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. [SOLVED] Could the "Criteria" in COUNTIF function be a cell reference?
    By N Harkawat in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 07:05 AM
  2. Could the "Criteria" in COUNTIF function be a cell reference?
    By N Harkawat in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  3. [SOLVED] Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  4. Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. Could the "Criteria" in COUNTIF function be a cell reference?
    By JohnSheenWSN in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-16-2005, 04:05 PM

Tags for this Thread

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