Left-align and right-align values in dynamic pop-up message (upon opening Excel)

skydivetom

New Member
Joined
Oct 26, 2017
Messages
5
Experts:

I would like some assistance with tweaking VBA output in a pop-up text box (upon opening Excel)... please see VBA code below:

As of now, the pop-up (data) is driven by values in the actual spreadsheet (I didn't know how to attach the sample file). Right now, the labels (A1:A3) are automatically left aligned. Values from column B, however, are not nicely aligned in the pop-up message. That is, the two currency values (B1:B2) are pushed over due to vbTab. And the % value is not aligned at all.

My question: How can modify the VBA in order to "right-align" any values from **column B** in the pop-up message?

Thank you,
EEH





Code:
Private Sub Workbook_Open()
          
    Dim strTxt As String
    strTxt = _
    Worksheets("PopUp Messages").Range("A1").Text & vbTab & Worksheets("PopUp Messages").Range("B1").Text & vbCrLf & _
    Worksheets("PopUp Messages").Range("A2").Text & vbTab & Worksheets("PopUp Messages").Range("B2").Text & vbCrLf & _
    Worksheets("PopUp Messages").Range("A3").Text & vbTab & Worksheets("PopUp Messages").Range("B3").Text
    MsgBox strTxt, vbOKOnly + vbInformation, "Pertinent Budget Data"
             
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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