Format Msgbox string from array of cells

lross

New Member
Joined
Aug 7, 2019
Messages
9
Hi,
I am trying to format a MsgBox string created from and array of cells. There are 3 columns in the cell range the 3rd of which have a % format. Msgbox writes the string as a decimal. Can anyone help with converting the range C2:C6 to a percentage the same as the source. I was trying to use the FORMAT() function without success

Cheers

>
Source data:
[TABLE="width: 295"]
<colgroup><col><col span="2"></colgroup><tbody>[TR]
[TD]1[/TD]
[TD]10[/TD]
[TD]0%[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]24[/TD]
[TD]10%[/TD]
[/TR]
[TR]
[TD]25[/TD]
[TD]49[/TD]
[TD]35%[/TD]
[/TR]
[TR]
[TD]50[/TD]
[TD]99[/TD]
[TD]40%[/TD]
[/TR]
[TR]
[TD]100[/TD]
[TD]999[/TD]
[TD]50%[/TD]
[/TR]
</tbody>[/TABLE]

Code:
Sub MsgBoxDiscount()
'Display the Discount Table in a popup
MsgString = Join(Evaluate("TRANSPOSE('Discounts'!A2:A6 & """ & vbTab & """ & 'Discounts'!B2:B6 & """ & vbTab & vbTab & """ & 'Discounts'!C2:C6 )"), vbNewLine)
MsgBox "Volume Range" & vbTab & "Discount" & vbCr & MsgString, , "Volume Discount Table"
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Welcome to the Mr Excel Board!

Since you are creating the string using Evaluate, you need to use the worksheet function TEXT instead of Format. Try:

Code:
Sub MsgBoxDiscount()
'Display the Discount Table in a popup
MsgString = Join(Evaluate("TRANSPOSE('Discounts'!A2:A6 & """ & vbTab & """ & 'Discounts'!B2:B6 & """ & vbTab & vbTab & """ & TEXT('Discounts'!C2:C6,""0.00%"") )"), vbNewLine)
MsgBox "Volume Range" & vbTab & "Discount" & vbCr & MsgString, , "Volume Discount Table"
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
Try
Code:
MsgString = Join(Evaluate("TRANSPOSE('Discounts'!A2:A6 & """ & vbTab & """ & 'Discounts'!B2:B6 & """ & vbTab & vbTab & """ & text('Discounts'!C2:C6,""0%"") )"), vbNewLine)
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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