Using the above VBA code, how can I set it up so that it scans column B for items in Bold and then displays how many items are in bold in Cell O3?
I would use slightly different code (see below) but to set up & use the UDF ..
1. With the relevant workbook active, Alt+F11 to open the VBA window.
2. Use the menu to Insert|Module
3. Copy and paste the code into the main right hand pane that opes at step 2.
4. Close the VBA window and enter a formula like this in O3:
=CountBold(B1:B100)
Notes:
1. You could use a whole column, =CountBold(B:B), but this will slow your sheet considerably since the code would need to check every cell in column B so best to restrict the range if you can.
2. This will count cells that are formatted as bold, even if they don't contain any value. If this doesn't suit then a firther check would need to be built in to the code.
3. If you subsequently (after the formula has been entered in O3) add/remove bolding from any of the target range, the UDF formula will not automatically update. It will only update when the something on the sheet is re-calculated.
<font face=Courier New><br><SPAN style="color:#00007F">Function</SPAN> CountBold(R <SPAN style="color:#00007F">As</SPAN> Range) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br> <SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range<br> <br> Application.Volatile<br> <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> R<br> <SPAN style="color:#00007F">If</SPAN> c.Font.Bold <SPAN style="color:#00007F">Then</SPAN> CountBold = CountBold + 1<br> <SPAN style="color:#00007F">Next</SPAN> c<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN><br><br></FONT>