I want a formula in excel that says if A1 is bold output "bold" otherwise do nothing
- User
I want a formula in excel that says if A1 is bold output "bold" otherwise do nothing
- Assistant
You can achieve this using a custom VBA function as Excel does not have a built-in function to check for bold text. To create a custom VBA function, follow these steps:
- Press
ALT + F11to open the Visual Basic for Applications (VBA) Editor. - Go to
Insert > Moduleto insert a new module. - Copy and paste the following code into the module:
Function IsBold(cell As Range) As String If cell.Font.Bold = True Then IsBold = "bold" Else IsBold = "" End If End Function- Press
CTRL + Sto save the module, and close the VBA Editor.
Now, you can use the custom
IsBold()function in your Excel worksheet. In the cell where you want the result, enter the following formula:=IsBold(A1)This formula will return "bold" if the text in cell A1 is bold; otherwise, it will return an empty string.
- Press
- User
can i write if a1 is bold then output (isbold)
- Assistant
Yes, you can modify the custom VBA function to return "(isbold)" instead of "bold" when the text in cell A1 is bold. To do this, follow these steps:
- Open the VBA Editor by pressing
ALT + F11. - Go to the module where you created the
IsBold()function earlier. - Modify the function as follows:
Function IsBold(cell As Range) As String If cell.Font.Bold = True Then IsBold = "(isbold)" Else IsBold = "" End If End Function- Press
CTRL + Sto save the module, and close the VBA Editor.
Now, you can use the custom
IsBold()function in your Excel worksheet. In the cell where you want the result, enter the following formula:=IsBold(A1)This formula will return "(isbold)" if the text in cell A1 is bold; otherwise, it will return an empty string.
- Open the VBA Editor by pressing
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.