+ Reply to Thread
Results 1 to 4 of 4

using countif into a formula

Hybrid View

Guest using countif into a formula 10-24-2005, 08:05 AM
Guest Re: using countif into a... 10-24-2005, 08:05 AM
Guest Re: using countif into a... 10-24-2005, 08:05 AM
Guest Re: using countif into a... 10-24-2005, 09:05 AM
  1. #1
    fuzzy
    Guest

    using countif into a formula

    I want to put a formula in a cell, to check if a range of cells
    contains one character.
    I think it seems like

    ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
    ";" & ""P"" & ")"

    where first_cell and last_cell are the bounds of a range
    and "P" is the character I want to check if it exists

    but it does not work


  2. #2
    XPete
    Guest

    Re: using countif into a formula

    This worked for me
    ;-)

    Dim myRange As Range
    Dim Formula As String

    Set myRange = Worksheets("Sheet1").Range("A1:C10")

    Formula = Application.WorksheetFunction.CountIf(myRange, "P")

    MsgBox Formula


  3. #3
    Mike Fogleman
    Guest

    Re: using countif into a formula

    One method is:

    Sub Frmula()
    Dim firstcell As String
    Dim lastcell As String
    firstcell = Range("A1").Address
    lastcell = Range("A13").Address
    Range("B1").Formula = "=COUNTIF(" & firstcell & ":" & lastcell & ",""p"")"
    End Sub

    Mike F

    "fuzzy" <fuzzy@in.gr> wrote in message
    news:1130152803.442839.282160@g14g2000cwa.googlegroups.com...
    >I want to put a formula in a cell, to check if a range of cells
    > contains one character.
    > I think it seems like
    >
    > ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
    > ";" & ""P"" & ")"
    >
    > where first_cell and last_cell are the bounds of a range
    > and "P" is the character I want to check if it exists
    >
    > but it does not work
    >




  4. #4
    Bob Phillips
    Guest

    Re: using countif into a formula

    Get the address of the cells, first_cell.address and last_cell.address

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "fuzzy" <fuzzy@in.gr> wrote in message
    news:1130152803.442839.282160@g14g2000cwa.googlegroups.com...
    > I want to put a formula in a cell, to check if a range of cells
    > contains one character.
    > I think it seems like
    >
    > ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
    > ";" & ""P"" & ")"
    >
    > where first_cell and last_cell are the bounds of a range
    > and "P" is the character I want to check if it exists
    >
    > but it does not work
    >




+ 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