Inserting Bold text into a cell

  • Thread starter Thread starter Ak Man
  • Start date Start date
A

Ak Man

Can someone help me out with this:
Cells(i + 1, j).Value = " Value 1 :- " & Str1(k) & " Value 2 :- " & Str2(k)
In this I want to have the texts "Value 1 :- " and " Value 2 :- " as Bold,
italic and with font as Tahoma (Just bold will also do)
 
Adapt this to suit

Sub boldtext()
Set mr = Range("l1")
mr.Font.Bold = False
mr.Value = "Value1: " & 11111 & " Value 2: " & 22222222
p1 = InStr(mr, ":")
MsgBox p1
p2 = InStr(mr, " Value 2")
MsgBox p2
p3 = InStr(p2, mr, ":")
MsgBox p3
mr.Characters(1, p1).Font.Bold = True
mr.Characters(p2, p3 - p2 + 1).Font.Bold = True
End Sub
 
Something like this should work...

With Cells(i + 1, j)
.Characters.Delete
.Value = " Value 1 :- " & k1 & " Value 2 :- " & k2
With .Characters(InStr(.Value, k1), Len(k1))
.Font.Name = "Tahoma"
.Font.Bold = True
.Font.Italic = True
End With
With .Characters(InStr(InStr(.Value, "Value 2"), .Value, k2), Len(k2))
.Font.Name = "Tahoma"
.Font.Bold = True
.Font.Italic = True
End With
End With

I think good practice would be to qualify your Cells(i + 1, j) reference
with a reference to the worksheet they are on.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top