User Define Function

bwchowdhury

New Member
Joined
Apr 14, 2018
Messages
1
I want to create my own function for making Bold a cell value.
Like this

=BOLD(A1)

Can anybody tell me the exact code in VBA editor under Function BOLD ?
Like this ...

function bold()

bold = ..........????.............

End function
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Welcome to the MrExcel board!

You could try this UDF. It will return ..

TRUE if the whole cell is formatted as Bold
FALSE if the whole cell is formatted as not Bold
0 if some characters are formatted as bold and some are not

Note that changing the formatting of a cell (eg from Bold to not Bold) will not automatically cause the function to update its value.
Code:
Function IsBold(r As Range) As Variant
  IsBold = r.Font.Bold
End Function
 
Upvote 0
I want to create my own function for making Bold a cell value.

If you meant this literally...that you want to MAKE the cell bold, then a function won't do that. Functions have rules they abide by, one of which is, they can't change the formatting or value of another cell.

Think of it like this, a function can test for value or formatting that is already set and use that information to return almost anything you want (sum/count/average/etc of bold cells...or yellow cells or italic cells or wingdings cells)......a subroutine can set value or formatting automatically.

If you want to MAKE the cell bold, you need a subroutine...maybe attached to a button on the worksheet.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top