+ Reply to Thread
Results 1 to 4 of 4

VBA Formula into Cell: Countif: Why doesn't this work???

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Portsmouth, VA now, Falmouth, VA 4 yrs, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    620

    VBA Formula into Cell: Countif: Why doesn't this work???

    I am going nuts on this and it has to be something stupid.:

    Worksheets(sSup).Range(sIRcol & Range(sAddress).Row + 1).Formula = "=COUNTIF(" & sIRcol & "2:" _
                                                                                         & sIRcol & Range(sAddress).Row & ",=Yes)"
    If I break it back to using COUNTA instead

                Worksheets(sSup).Range(sIDCol & Range(sAddress).Row + 1).Formula = "=COUNTA(" & sIDCol & "2:" _
                                                                                          & sIDCol & Range(sAddress).Row & ")"
    and trim off the
    ,=Yes
    it operates just as a COUNTA should, so I can not understand it! (I have verified that the variables when changed over to the COUNTIF example do have valid information).

    sSup = string name of a tab
    sIRcol = string name of a columne, such as "I"
    sAddress = string of an address, such as "I36"

    What have I done???

    Many thanks, frustration has gotten the better of me so I am probably not thinking straight...

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

    Re: VBA Formula into Cell: Countif: Why doesn't this work???

    You are missing few speech marks on strings ""Yes""

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: VBA Formula into Cell: Countif: Why doesn't this work???

    You need quotes round the =Yes:
    Worksheets(sSup).Range(sIRcol & Range(sAddress).Row + 1).Formula = "=COUNTIF(" & sIRcol & "2:" _
                                                                                         & sIRcol & Range(sAddress).Row & ",""=Yes"")"
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Portsmouth, VA now, Falmouth, VA 4 yrs, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    620

    Re: VBA Formula into Cell: Countif: Why doesn't this work???

    It must have been the frustration.

    I thought I tried every combination physically possible.

    I even tried combinations I swore were idiotic to try.

    Thank-you so much. You folks are GREAT.
    Live and learn...

+ 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] COUNTIF Formula with DOES NOT EQUAL TO operator doesn't work
    By JPWRana in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 07-20-2013, 06:10 PM
  2. [SOLVED] formula works in cell but doesn't work in vba
    By maleeny31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2013, 12:36 AM
  3. Insert formula into a cell doesn't work :S
    By s80NL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2006, 12:05 PM
  4. [SOLVED] Countif statement doesn't work on some rows
    By Carpo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-14-2006, 12:25 PM
  5. countif criteria only one word of few doesn't work
    By dcd123 in forum Excel Formulas & Functions
    Replies: 41
    Last Post: 09-06-2005, 07:05 PM

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