add specific currency to textbox on userform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hello
I try adding specific currency to numbers into textbox i would show the number in textbox like this LYD 120,000.00
this is my try
VBA Code:
Private Sub TextBox1_Change()
With Me.TextBox1
Dim s As Currency
s = LYD
        If IsNumeric(.Value) Then .Value = Format(.Value, "#,##0.00" & s)
    End With
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi
VBA Code:
Try
.....=Format(CStr(.Value), "#,##0.00") & " s"
 
Upvote 0
thanks but it doesn't work this is what shows
1.JPG
 
Upvote 0
OOOOPs
VBA Code:
.....=Format(CStr(.Value), "#,##0.00") & " " & s
 
Upvote 0
VBA Code:
Dim s As String
s="LYD"

Or you mean
VBA Code:
Private Sub TextBox1_Change()
With Me.TextBox1
Dim s As String
s = "LYD"
        If IsNumeric(.Value) Then .Value = s & " " & Format(CStr(.Value), "#,##0.00")
    End With
End Sub
 
Last edited:
Upvote 0
about post #5 it doesn't change as for post # 6 it gives me error mismatch in this
VBA Code:
s="LYD"
 
Upvote 0
yes but not completely should show for any number like this LYD 1,122,122.00 OR LYD100.00
 
Upvote 0
Then
VBA Code:
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
With Me.TextBox1
Dim s As String
s = "LYD"
        If IsNumeric(.Value) Then
        .Value = s & " " & Format(CStr(.Value), "#,##0.00")
        End If
    End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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