+ Reply to Thread
Results 1 to 5 of 5

Bold part of text that appears before special character

  1. #1
    Registered User
    Join Date
    03-21-2016
    Location
    SG
    MS-Off Ver
    2010
    Posts
    23

    Bold part of text that appears before special character

    Hi,

    I want to bold part of the text that appears before the character (-) in column G.
    I want to do this activity for all the open excel sheets.

    Example
    Column G (row 2) has entries like SOCCER_FOOTBALL_PLAYER - Player who plays soccer football--> I want to bold only SOCCER_FOOTBALL_PLAYER.

    This has to be applied in all the rows in column G which has entries and all open excel sheets.

    Appreciate can share some code as I am newbie with macros.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Bold part of text that appears before special character

    You could try with this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    03-21-2016
    Location
    SG
    MS-Off Ver
    2010
    Posts
    23

    Re: Bold part of text that appears before special character

    Thanks Antonio for your efforts.
    I want to do this activity for all open excel sheets, so i modified the code as below
    Sub Macro1()
    Dim lastRow As Long, r As Long, pos As Integer
    For Each wbkX In Application.Workbooks
    wbkX.Activate
    lastRow = .Cells(Rows.Count, "g").End(xlUp).Row
    For r = 2 To lastRow
    pos = InStr(.Cells(r, "g"), "-")
    If pos > 0 Then
    .Cells(r, "g").Characters(Start:=1, Length:=pos - 1).Font.Bold = True
    End If
    Next r

    Next
    End Sub

    I am getting error Invalid or unqualified reference in line --> lastRow = .Cells(Rows.Count, "g").End(xlUp).Row. Please advise

    http://www.ozgrid.com/forum/showthread.php?t=199616

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Bold part of text that appears before special character

    Do you mean like this?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-21-2016
    Location
    SG
    MS-Off Ver
    2010
    Posts
    23

    Re: Bold part of text that appears before special character

    Thanks Jindon and Antoka. It helped me to solve my problem.
    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Seperate text using special character
    By specialt1212 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-02-2016, 12:04 AM
  2. [SOLVED] How to Bold a Part of the text?
    By SMILE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2014, 06:21 AM
  3. Replies: 8
    Last Post: 04-22-2013, 12:24 PM
  4. [SOLVED] How to make part of the text in a cell bold
    By aymanzone in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2012, 05:26 AM
  5. [SOLVED] Display text before special character
    By matthewdbeard in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2012, 05:44 PM
  6. [SOLVED] Only part of Comment text appears
    By mjkahn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2006, 12:10 PM
  7. Replies: 3
    Last Post: 12-09-2005, 03:10 PM

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