Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bolding a text 1

Status
Not open for further replies.

kenguru

Programmer
May 14, 2004
173
RO

Hello,

How can i bold a part of a text?

Thank you,
Kenguru
 
In what? HTML? Word? WordPad? Some completely other application? On a piece of paper?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 



Turn on your macro recorder.

Do the formatting.

Observe the code.

Skip,

[glasses] [red][/red]
[tongue]
 
Hello,

In VBA, in Excel.

I did that Skip, but i didn't found nothing which i could use generally.

Kenguru
 
So post what you got and we can help you generalize it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Range("E27").Select
ActiveCell.FormulaR1C1 = "160GB, 7200rpm/S-ATA/8MB, WD1600JD"
With ActiveCell.Characters(Start:=8, Length:=7).Font
.Name = "Arial Narrow"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
 
I would need the following for example:
find the world "7200" and bold it.

Thank you, kenguru
 


Code:
Sub BoldValue()
    Dim s As String, p As Integer
    
    s = "7200"
    
    With Selection
        .FormulaR1C1 = "160GB, 7200rpm/S-ATA/8MB, WD1600JD"
        p = InStr(.Value, s)
        If p > 0 Then
            .Characters(Start:=p, Length:=Len(s)).Font.Bold = True
        End If
    End With
End Sub


Skip,

[glasses] [red][/red]
[tongue]
 
Is this line necessary:
.FormulaR1C1 = "160GB, 7200rpm/S-ATA/8MB, WD1600JD"

Because it is not necessary the "7200" in this text.

Thank You,
Kenguru
 
I would need something like this:
Sub bolding()
Dim i As Long
Dim s As String, p As Integer

For i = ActiveWindow.RangeSelection.Row To ActiveWindow.RangeSelection.Rows(ActiveWindow.RangeSelection.Rows.Count).Row

s = "7200"

With Selection '--> at this part should i change it, only i don't know how
p = InStr(.Value, s)
If p > 0 Then
.Characters(Start:=p, Length:=Len(s)).Font.Bold = True
End If
End With
Next i

End Sub

***********************
Evidentlly my conversion is not good. Any idea how could i make it better?

Thank you
 

Code:
Sub bolding()
Dim i As Long
Dim s As String, p As Integer
   s = "7200"
   For i = Selection.Row To Selection.Row + Selection.Rows.Count - 1
               
    With ActiveSheet.Cells(i, Selection.Column)         p = InStr(.Value, s)
        If p > 0 Then
            .Characters(Start:=p, Length:=Len(s)).Font.Bold = True
        End If
    End With
   Next i

End Sub

Skip,

[glasses] [red][/red]
[tongue]
 
You are good !!! Thank's !!! You deserve totally the point :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top