Format contents of msg box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The code below produces a msg box with a value formatted with 4 decimal
places and no dollar sign. How would I code it to 0 decimal places and a
dollar sign?

Sub GetBalance()
Dim x As String
Dim y As Currency
x = Range("B65536").End(xlUp).Activate ' does work
y = ActiveCell.Offset(, 4).Value
MsgBox y
End Sub
 
Hi jmd:

A couple more examples to add to JE's

Private Sub CommandButton4_Click()

' Returns "$ 5,459.40".
Message1 = Format(5459.4, "$ ##,##0.00")
' Returns "$ 500.00" if 500 in M37
Message2 = Format(Range("M37"), "$ ##,##0.00")
' Returns string in M36 in upper case
Message3 = Format(Range("M36"), ">")

MsgBox Message1
MsgBox Message2
MsgBox Message3

End Sub
 
Thank you!

TK said:
Hi jmd:

A couple more examples to add to JE's

Private Sub CommandButton4_Click()

' Returns "$ 5,459.40".
Message1 = Format(5459.4, "$ ##,##0.00")
' Returns "$ 500.00" if 500 in M37
Message2 = Format(Range("M37"), "$ ##,##0.00")
' Returns string in M36 in upper case
Message3 = Format(Range("M36"), ">")

MsgBox Message1
MsgBox Message2
MsgBox Message3

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top