ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Bold text into a cell (https://www.excelbanter.com/excel-programming/414997-inserting-bold-text-into-cell.html)

Ak Man

Inserting Bold text into a cell
 
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)

--
Ak

Don Guillett

Inserting Bold text into a cell
 
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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ak Man" wrote in message
...
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)

--
Ak



Rick Rothstein \(MVP - VB\)[_2458_]

Inserting Bold text into a cell
 
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


"Ak Man" wrote in message
...
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)

--
Ak




All times are GMT +1. The time now is 06:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com