+ Reply to Thread
Results 1 to 6 of 6

Countif + Left VBA code

Hybrid View

MJW Countif + Left VBA code 12-09-2011, 02:28 PM
tigeravatar Re: Countif + Left VBA code 12-09-2011, 02:40 PM
MJW Re: Countif + Left VBA code 12-09-2011, 02:46 PM
tigeravatar Re: Countif + Left VBA code 12-09-2011, 02:48 PM
tigeravatar Re: Countif + Left VBA code 12-09-2011, 02:49 PM
MJW Re: Countif + Left VBA code 12-09-2011, 02:52 PM
  1. #1
    Registered User
    Join Date
    10-20-2011
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    12

    Countif + Left VBA code

    Hi All,

    I'm trying to figure out code that will scan all cells in a column, W, and return a count of how many of the cell values start with a particular text string, for our purposes , "XYZ". I know how to do this with a helper column but can't figure out how to do it without one and i'd prefer not to have a helper column if at all possible.

    Thanks for your help!
    Last edited by MJW; 12-09-2011 at 02:53 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Countif + Left VBA code

    MJW,

    Something like this?
    Sub tgr()
        
        MsgBox [COUNTIF(W:W,"XYZ*")]
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    10-20-2011
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Countif + Left VBA code

    Sorry, i should have been more specific. i need it to return the value to a cell. for instance AA1.

    thanks!

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Countif + Left VBA code

    Sub tgr()
        
        Range("AA1").Value = [COUNTIF(W:W,"XYZ*")]
        
    End Sub

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Countif + Left VBA code

    Also, its worth noting that VBA isn't required for this. You could simply put this formula in cell AA1:
    =COUNTIF(W:W,"XYZ*")

  6. #6
    Registered User
    Join Date
    10-20-2011
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Countif + Left VBA code

    yep, right after i posted that i figured out how to return it to a cell. its part of a much bigger macro and i'm trying to foolproof it for the end user. I've never used the [] before in that way so mine looks slightly different but works all the same. Thanks for your help!

+ 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