+ Reply to Thread
Results 1 to 15 of 15

Need to underline specific word in text string?

  1. #1
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Need to underline specific word in text string?

    Hi there,

    Just wondering if someone could help me with my memory block?

    I'm simply wanting a VBA routine to double underline the word "PROJECT" in line 5.

    Many thanks,

    Jerry
    Attached Files Attached Files

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: Need to underline specific word in text string?

    Maybe the below will help:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Need to underline specific word in text string?

    Or this:
    Please Login or Register  to view this content.
    BSB

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Need to underline specific word in text string?

    May be:
    PHP Code: 
    Option Explicit
    Sub DoubleLine
    ()
    Dim faddr As String
    Set f 
    Rows(5).Find("*PROJECT*")
    If 
    Not f Is Nothing Then
        addr 
    f.Address
        f
    .Font.Underline xlNone
        f
    .Characters(InStr(1f"PROJECT"), 7).Font.Underline xlUnderlineStyleDouble
        
    Do
            
    Set f Rows(5).FindNext(f)
            If 
    Not f Is Nothing Then
                f
    .Font.Underline xlNone
                f
    .Characters(InStr(1f"PROJECT"), 7).Font.Underline xlUnderlineStyleDouble
            End 
    If
        
    Loop Until f.Address addr
    End 
    If
    End Sub 
    Quang PT

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

    Re: Need to underline specific word in text string?

    Quote Originally Posted by afterdinnerspeak View Post
    I'm simply wanting a VBA routine to double underline the word "PROJECT" in line 5.
    In case of the multiple appearances in the same cell.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Greetings BadlySpelledBuoy,

    Thanks so much for the code you provided.

    I really don't know why I'm getting this compile error re: "Expected End Sub"?

    Regards,

    Jerry
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Thank you so much CheeseSandwich,

    I really appreciate your response.

    I'm having problems testing your code and I'm sure it's something I'm doing wrong!

    I keep getting the attached Compile error "Expected End Sub" so it's definitely something I'm doing wrong!

    Any thoughts?

    Jerry
    Attached Images Attached Images

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: Need to underline specific word in text string?

    "End Sub" statement missing ?

    See attached which has macros from replies.
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  9. #9
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Thanks very kindly JohnTopley!

    I've been unable to view the macro due to security message.

    Would you mind providing it to me?

    Many thanks,

    Jerry

  10. #10
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Sorry BadlySpelledBuoy,

    I made a mistake testing the macro and got the Compile error...my bad!

    I noticed the double underlined text is not very noticeable so, instead of applying a double line, would it be possibe to just increase the "size" of the font for the word "PROJECT"?

    Thanks so much,

    Jerry

  11. #11
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Sorry CheeseSandwich,

    I made a mistake testing the macro and got the Compile error...my bad!

    Many thanks again,

    Jerry

  12. #12
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Dear bebo021999,

    I just want to thank you for your kind response to my question!

    Have a great day,

    Jerry

  13. #13
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Thank you so much jindon!

    I really appreciate your response.

    I noticed the double underlined text is not very noticeable so, instead of applying a double line, would it be possibe to just increase the "size" of the font for the word "PROJECT"?

    Very Grateful,

    Jerry

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: Need to underline specific word in text string?

    Try

    Please Login or Register  to view this content.
    BSB macro

  15. #15
    Registered User
    Join Date
    03-30-2023
    Location
    Calgary, AB
    MS-Off Ver
    Office Home & Business 2019
    Posts
    10

    Re: Need to underline specific word in text string?

    Thanks so much JohnTopley!

    Works just as expected with no problems.

    Have a great day,

    Jerry

+ 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. [SOLVED] If a cell contains a specific word, return pre defined string for that word.
    By slamont in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-23-2022, 01:19 PM
  2. Underline a specific part of a text string (inc formulas) using VBA.
    By Oriya in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-06-2019, 05:56 AM
  3. [SOLVED] duplicate specific text and underline it
    By Ethen5155 in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2019, 12:31 PM
  4. [SOLVED] COUNTIF cells contain a specific word anywhere within the text string
    By RoundaboutCJP in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-18-2018, 12:38 PM
  5. [SOLVED] find the position of an underline word in string.
    By mouaffaq in forum Excel General
    Replies: 6
    Last Post: 11-27-2016, 05:59 AM
  6. [SOLVED] Formula that takes takes out a specific word/number from text string
    By ncalvelo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2012, 10:21 AM
  7. Extract specific word from a text string
    By krjoshi in forum Excel General
    Replies: 10
    Last Post: 01-19-2012, 02:00 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