is there any way to get a formula to count only the entries that are in bold abd ignore all others
is there any way to get a formula to count only the entries that are in bold abd ignore all others
Hi,
Prehaps this code will help.
Press Alt + F11 and paste this code into a module
http://www.contextures.com/xlvba01.html#Regular
Then use a forumla likePlease Login or Register to view this content.
=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 !!!
thanks seems like what i need but i donyt know how to run the code any help appreciated
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?
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?
Good morning jimb0693
Have a look at the attached spreadsheet.
Paul
No Paul, it can't, but you are thinking on the right lines.Sidenote to VBANoob - could the 'Application.Volatile' statement be added so that the formula recalcs automatically? Or am I thinking of something else?
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.
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?
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
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks