PDA

View Full Version : [SOLVED:] Trying to make specific cell contents bold



HTSCF Fareha
04-21-2021, 12:10 AM
I have the following in my sub for which I would like the word 'Highlight' to be bold.


If Application.WorksheetFunction.CountA(Sheets("Highlight Markers").Cells) <> 0 Then

Sheets("Highlight Markers").Range("A1") = "Highlight"
Sheets("Highlight Markers").Range("A2") = "These are the rest :-"

ElseIf Application.WorksheetFunction.CountA(Sheets("Highlight Markers").Cells) = 0 Then
Sheets("Highlight Markers").Range("A1") = "Highlight"
Sheets("Highlight Markers").Range("A2") = "Nothing to report that is of any noteworthiness"
End If

If I use
Sheets("Highlight Markers").Range("A1").Font.Bold = "Highlight" then nothing happens. If I use
Sheets("Highlight Markers").Range("A1") = "Highlight"
Selection.Font.Bold = True then everything is made bold.

Thanks!
Steve

rollis13
04-21-2021, 02:42 AM
Something wrong here:

Sheets("Highlight Markers").Range("A1").Font.Bold = "Highlight"

should be:

Sheets("Highlight Markers").Range("A1").Font.Bold = TrueIn the second case you are making 'Selection.' bold, but what have you selected ?
Sheets("Highlight Markers").Range("A1") = "Highlight"fills a cell, doesn't select it.

HTSCF Fareha
04-21-2021, 04:05 AM
I used option one, but this did not input the word "Highlight", so I ended up with a completely empty cell which also did not have bold assigned to it.

I was hoping that the selection would be focussed on the Range A1.

I have also tried this, which didn't do anything.


Sheets("Highlight Markers").Range("A1").Font.Bold("Highlight") = True

p45cal
04-21-2021, 04:26 AM
With Sheets("Highlight Markers").Range("A1")
x = InStr(1, .Value, "highlight", vbTextCompare)
If x > 0 Then .Characters(Start:=x, Length:=9).Font.FontStyle = "Bold"
End With

rollis13
04-21-2021, 04:30 AM
This is the only other way I know:
With Sheets("Highlight Markers")
.Range("A1") = "Highlight"
.Range("A1").Font.Bold = True
End With

HTSCF Fareha
04-21-2021, 05:54 AM
My thanks to both p45cal and rollis13!

Both alternatives work, although p45cal's version allows the specification of how many characters to make bold counting from the left.

Many thanks!
Steve