Underline a specific part of a text string using VBA.

PUGresources

New Member
Joined
Aug 6, 2019
Messages
7
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?

<tbody>
</tbody>

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, but I've got no idea how to adapt this as my vba is really not good enough!

Can anyone help please?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the forum. :)

Please take a minute to read the forum rules, especially related to cross-posting, and then add the relevant links here to your post(s) in any other forum(s). Thanks.
 
Upvote 0
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?

<tbody>
</tbody>

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&"?")
You cannot format any part of the output from a formula differently from the rest of the output from that formula, you can only do that with a constant value. To do what you want would require you to use event code to duplicate the functionality of your formula outputting its result as a constant value to the cell and then change the format for a part of that constant.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top