Consulting

Results 1 to 4 of 4

Thread: Solved: counting

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    Solved: counting

    Hi

    I need some help with a macro that will count the amount of cells in column "b" that the cells containment is greater than 5


    thanks

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Try either:

    Sub exa()
        MsgBox Evaluate("=COUNTIF(Sheet1!B:B,"">5"")")
        MsgBox WorksheetFunction.CountIf(Sheet1.Range("B:B"), ">5")
    End Sub
    Hope that helps,

    Mark

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi
    thanks it works fine
    i wanted to ask if i want to replace "5" with a variable
    what should i do

    thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    MsgBox Application.CountIf(Sheet1.Range("B:B"), ">" & myVar)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •