+ Reply to Thread
Results 1 to 4 of 4

Count specific characters with numbers or letters

  1. #1
    Registered User
    Join Date
    10-09-2007
    Posts
    2

    Count specific characters with numbers or letters

    I have hundreds of spreadsheets with information broken into sections. These sections are all classified by a "title" such as "A-1" or "WC-2" or "P-3", etc. I need to count how many "sections" there are so I would like to count how many "titles" are on one spreadsheet. Can anyone help me?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Hoppscrouse.

    This macro will return total number of "titles" on the worksheet. For the "title" to be considered valid it must have the following format:
    1. The left side of the hyphen must have at least one upper case letter A - Z
    2. The right side must have at least one number 0 - 9

    Paste this code into a Standard VBA Module
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Right Click on any Sheet's tab
    4. Left Click on View Code in the pop up menu
    5. Press the keys ALT+I to activate the Insert menu
    6. Press M to insert a Standard Module
    7. Paste the code by pressing the keys CTRL+V
    8. Make any custom changes you need to the macro
    9. Save the Macro by pressing the keys CTRL+S

    Sincerly,
    Leith Ross

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    =COUNTIF(A:IV,"*?-?*") will return the number of cells that have a hyphen, but do not begin or end with a hyphen.

  4. #4
    Registered User
    Join Date
    10-09-2007
    Posts
    2

    Smile It Worked!!

    Leith, Thank you so much. This is awesome!!!


    Quote Originally Posted by Leith Ross
    Hello Hoppscrouse.

    This macro will return total number of "titles" on the worksheet. For the "title" to be considered valid it must have the following format:
    1. The left side of the hyphen must have at least one upper case letter A - Z
    2. The right side must have at least one number 0 - 9

    Paste this code into a Standard VBA Module
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Right Click on any Sheet's tab
    4. Left Click on View Code in the pop up menu
    5. Press the keys ALT+I to activate the Insert menu
    6. Press M to insert a Standard Module
    7. Paste the code by pressing the keys CTRL+V
    8. Make any custom changes you need to the macro
    9. Save the Macro by pressing the keys CTRL+S

    Sincerly,
    Leith Ross

+ 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