Excel VBA Underline text guide

posted in: Excel Tutorials | 0

Excel VBA Underline text guide

excel tutorials for dummies

Underline VBA Tutorial

In this tutorial we outline how you can use VBA code to make selected text appear in Underline. This is very useful if you have a macro that enters new text and you would like that text to appear in Underline automatically. Our Underline VBA code is very simple and can be applied to many different macros where you wish to use VBA to format text.

Font Underline VBA guide

In our working example, we have a simple macro that selects cells A6 to F6 on Sheet1  and then uses Underline VBA code to make the text in those selected cells Underline. This is executed by an ActiveX button press that we have entitled “Excel VBA Underline”. The image below is before the macro is executed.

excel vba underline text

Excel VBA Underline Text code

The code that we used in our example is as follows and will need to be edited to fit into your own macros for your own purposes. You will need to change the ranges to match the selection for the text that you wish to make Underline, the rest of the code can be left unaltered. Please visit our guide on how to edit macro code to fit your own needs if you are unsure of this process.

Private Sub CommandButton1_Click()


Selection.Font.Underline = True

End Sub

Once the macro has run, the cells you selected should have been formatted in Underline, such as our example image below.

VBA Format Text Underline example

excel vba underline text

This concludes our Excel VBA Underline text guide. If you have struggled to follow along with any of this process then please visit the beginner’s guide which will help you get started and able to follow this guide comprehensively.

If you have struggled with any of this process, please also view the associated video tutorial which can be found below.

Excel VBA Underline Video Tutorial

For further Microsoft Excel Tutorials please visit my YouTube channel, a video like or subscribe is always appreciated.


Leave a Reply