+ Reply to Thread
Results 1 to 9 of 9

Underline a specific part of a text string (inc formulas) using VBA.

  1. #1
    Registered User
    Join Date
    01-25-2018
    Location
    london
    MS-Off Ver
    365
    Posts
    43

    Underline a specific part of a text string (inc formulas) using VBA.

    Hey all,

    Currently I'm working on a question that i'd like to look like this:
    What is the value of the underlined digit in 8512?

    The digit i'd like to underline is in cell X6 and the text string is in cell C9 (the formula for which is ="What is the value of the underlined digit in "&Y6&"?")

    I'd like to have VBA code that is dynamic and picks up that i want "5" underlined from cell X6 and does it in cell C9.

    I've also got a range of data (so, i'd like this to be applied to all of the range too) the value I want underlined from X6:X45 and the questions in the range C9:C48.

    I found this about underlining in a string and tried to have a go myself,

    Please Login or Register  to view this content.
    but I've got no idea how to adapt this as my vba is really not good enough!

    Can anyone help please?
    Last edited by Oriya; 08-06-2019 at 04:32 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Underline a specific part of a text string using VBA.

    You cannot underline part of the result of a formula, so you would have to replace the formulas with their results. Is that an issue?
    Rory

  3. #3
    Registered User
    Join Date
    01-25-2018
    Location
    london
    MS-Off Ver
    365
    Posts
    43

    Re: Underline a specific part of a text string using VBA.

    The number in y6 is a random number between 1000 and 9999 at the moment, I basically want to have the questions able to be updated to totally new questions every time the page calculates.

    I'm assuming from what you said that this isn't possible to keep it as is?

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    Certainly not exactly as is, though you could use the Worksheet_Calculate event to copy the formula result somewhere and then underline the relevant character.

  5. #5
    Registered User
    Join Date
    01-25-2018
    Location
    london
    MS-Off Ver
    365
    Posts
    43

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    I'd not have an issue with it being changed at all but I've no idea how to use the Worksheet_Calculate to do that.

  6. #6
    Registered User
    Join Date
    01-25-2018
    Location
    london
    MS-Off Ver
    365
    Posts
    43

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    Also really sorry, i've cross posted this in another forum, but it wont let me post the link

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    It would be something like this (air code):

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-25-2018
    Location
    london
    MS-Off Ver
    365
    Posts
    43

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    Thank you so much! It worked perfectly! I thought it didn't for a while but it turn out the underline font thing was on.

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Underline a specific part of a text string (inc formulas) using VBA.

    Glad to help, and thanks for the rep.

+ 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] duplicate specific text and underline it
    By Ethen5155 in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2019, 12:31 PM
  2. Replies: 2
    Last Post: 03-18-2015, 07:30 PM
  3. [SOLVED] Delete a row if a cell contains certain text as part of a text string
    By Steve2107 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2014, 07:49 PM
  4. [SOLVED] Can I remove the first part of a string of text and keep the second part?
    By Whoop92 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 02-12-2014, 07:44 PM
  5. Match text in A1 to a part of a text string in B1 and enter data D1
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2013, 10:16 PM
  6. [SOLVED] Extracting specific part of the text string to another column
    By ssanjju in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 01-20-2013, 07:20 PM
  7. [SOLVED] Finding specific text in string - Part II
    By Hardip in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-08-2006, 09:25 AM

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