+ Reply to Thread
Results 1 to 10 of 10

count only bold entries

  1. #1
    Registered User
    Join Date
    12-29-2005
    Posts
    90

    count only bold entries

    is there any way to get a formula to count only the entries that are in bold abd ignore all others

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Prehaps this code will help.

    Press Alt + F11 and paste this code into a module

    http://www.contextures.com/xlvba01.html#Regular

    Please Login or Register  to view this content.
    Then use a forumla like

    =CountBold(A1:A10)

    To recalc press F9.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    12-29-2005
    Posts
    90
    thanks seems like what i need but i donyt know how to run the code any help appreciated

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    jim,

    In your worksheet, press ALT+F11. Then, you should see in the left-hand column something like 'VBA Projects (YourWorkbookName.xls)'. Left-click on that and choose Insert -> Module.

    Copy and paste VBANoob's code into that module, then close the VBA window. Save your file.

    Now, from any cell in that workbook, you can type the formula:

    =COUNTBOLD(whatever_range_you_want)

    For example, if you wanted to count the bold-text cells in the range A5 to B10, use the formula

    =COUNTBOLD(A5:B10)

    Once you press enter, that cell will tell you how many cells are formatted as bold font in the range you specified.

    Sidenote to VBANoob - could the 'Application.Volatile' statement be added so that the formula recalcs automatically? Or am I thinking of something else?

  5. #5
    Registered User
    Join Date
    12-29-2005
    Posts
    90
    tried this following through step by step but when i type the "=COUNTBOLD(AM9:AM72) all i get is a message box saying "ambiguous name detected" then the cell just shows "#name?". i recon i must be doing something wrong but what?

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning jimb0693

    Have a look at the attached spreadsheet.

    Paul
    Sidenote to VBANoob - could the 'Application.Volatile' statement be added so that the formula recalcs automatically? Or am I thinking of something else?
    No Paul, it can't, but you are thinking on the right lines.

    Application.Volatile will force a calculation to update automatically but for reasons known only to Microsoft it won't work when you are using a formula that interacts with formats (colours / bold / italic etc). As the Application.Volatile command uses its own little slice of processing power, and it's compeltely irrelevant in this instance theres no real point in using it.

    HTH

    DominicB
    Last edited by dominicb; 08-19-2008 at 04:29 AM.
    Please familiarise yourself with the rules before posting. You can find them here.

  7. #7
    Registered User
    Join Date
    12-29-2005
    Posts
    90
    its working ok on my desktop with excel 97 but not on my laptop with excel 2003 is there a difference between the 2 versions that could cause this result?

  8. #8
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jimb0693

    There shouldn't be. The file I uploaded was done using Excel 2003.
    You're not using Excel 2003 Viewer are you? If so, that's not capable of running macros.

    If that's not the case the only other thing I can think of is that you left some components off when you installed the software. I can't remember whether you can leave out VBA in its entirety when you install Office...?

    HTH

    DominicB

  9. #9
    Registered User
    Join Date
    12-29-2005
    Posts
    90
    not viewer full version but was installed for me at work so dont know if anything missed, vba definitely installed as i have a number of macros running for various tasks. i think, until i check with the guy who installed that we've gone as far as possible.

    thanks vba noob, pjoaquin, dominicb for all your help i will follow this up and let you know what my installer says.

    thanks again

  10. #10
    Registered User
    Join Date
    12-29-2005
    Posts
    90
    finally got it working but not really sure what acomplished the result. the only thing i tried was moving the piece of code to module 1 instead of module 8 where i had it originally, dont see how this could affect it but its the only change i made. strange but sorted now

+ 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