+ Reply to Thread
Results 1 to 6 of 6

Make text partly bold, but failed

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-01-2010
    Location
    Jakarta
    MS-Off Ver
    Excel 2003
    Posts
    101

    Make text partly bold, but failed

    How to get only the first string bold and not the remaining text? At this stage all is bold.

    StrMeetingCSC = "Meeting CSC"
    StrOffice = "Office"
    .Value = StrMeetingCSC & Chr(10) & StrOffice
    .Characters(Start:=1, Length:=Len(StrMeetingCSC)).Font.Bold = True

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Make text partly bold, but failed

    You need to specify the cell you need to make partially bold
        StrMeetingCSC = "Meeting CSC"
        StrOffice = "Office"
    
        With Range("A1")
            .Value = StrMeetingCSC & Chr(10) & StrOffice
            .Characters(Start:=1, Length:=Len(StrMeetingCSC)).Font.Bold = True
        End With

    Change A1 to suit your needs

    Hope this helps

    [EDIT]
    You will need to add this line to the with statement if your code is to run more than once

            .ClearFormats
    Last edited by Marcol; 10-10-2010 at 06:40 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Contributor
    Join Date
    10-01-2010
    Location
    Jakarta
    MS-Off Ver
    Excel 2003
    Posts
    101

    Re: Make text partly bold, but failed

    I have it worked, but after selection, the proram has to go to all cells to ClearFormat which takes 3 seconds. Any faster solution?

      .ClearFormats
      StrMeetingCSC = "Meeting CSC"
      StrOffice = "Office"
      With sRng
        .Value = StrMeetingCSC & Chr(10) & IIf(TglbMeetingRoom.Value = True, "[M] ", "[  ] ") & StrOffice & IIf(TglbBeamer.Value = True, " [B]", " [  ]")
        .Characters(Start:=1, Length:=Len(StrMeetingCSC)).Font.Bold = True
      End With

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Make text partly bold, but failed

    As I said, add
     .ClearFormats
    to the With statement
      StrMeetingCSC = "Meeting CSC"
      StrOffice = "Office"
      With sRng
        .ClearFormats
        .Value = StrMeetingCSC & Chr(10) & IIf(TglbMeetingRoom.Value = True, "[M] ", "[  ] ") & StrOffice & IIf(TglbBeamer.Value = True, " [b]", " [  ]")
        .Characters(Start:=1, Length:=Len(StrMeetingCSC)).Font.Bold = True
      End With

    Hope this helps

  5. #5
    Forum Contributor
    Join Date
    10-01-2010
    Location
    Jakarta
    MS-Off Ver
    Excel 2003
    Posts
    101

    Re: Make text partly bold, but failed

    I did, but then merging will not proceed. The code is part of a bigger command.

    Private Sub CmdMeetingCSC_Click()
    On Error GoTo error_handler
    RepeatInputBoxMeetingCSC:
    Set sRng = Application.InputBox(prompt:="Select period for this Event", Left:=30, Top:=80, Type:=8)
    With sRng
      If sRng.Rows.Count > 1 Then
        Set sRng = Nothing
        MsgBox "You selected more then one Row! Select the correct Period for this Event"
        GoTo RepeatInputBoxMeetingCSC
      End If
      .HorizontalAlignment = xlCenter
      .VerticalAlignment = xlCenter
      .MergeCells = True
      StrMeetingCSC = "Meeting CSC"
      StrOffice = "Office"
      With sRng
        .ClearFormats
        .Value = StrMeetingCSC & Chr(10) & IIf(TglbMeetingRoom.Value = True, "[M] ", "[  ] ") & StrOffice & IIf(TglbBeamer.Value = True, " [B]", " [  ]")
        .Characters(Start:=1, Length:=Len(StrMeetingCSC)).Font.Bold = True
      End With
    If OpBProposed.Value = True Then sRng.Interior.ColorIndex = 35
    If OpBScheduled.Value = True Then sRng.Interior.ColorIndex = 4
    If OpBConfirmed.Value = True Then sRng.Interior.ColorIndex = 50
    End With
    error_handler:
    Exit Sub
    End Sub

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Make text partly bold, but failed

    Where does merging cells come from?

    Best you show a bit more of your code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1