add specific currency to textbox on userform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
963
Office Version
  1. 2010
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
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
918
Office Version
  1. 2013
Platform
  1. Windows
Hi
VBA Code:
Try
.....=Format(CStr(.Value), "#,##0.00") & " s"
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
963
Office Version
  1. 2010
thanks but it doesn't work this is what shows
1.JPG
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
918
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

OOOOPs
VBA Code:
.....=Format(CStr(.Value), "#,##0.00") & " " & s
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
918
Office Version
  1. 2013
Platform
  1. Windows
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:

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
963
Office Version
  1. 2010

ADVERTISEMENT

about post #5 it doesn't change as for post # 6 it gives me error mismatch in this
VBA Code:
s="LYD"
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
963
Office Version
  1. 2010
yes but not completely should show for any number like this LYD 1,122,122.00 OR LYD100.00
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
918
Office Version
  1. 2013
Platform
  1. Windows
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
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,122,850
Messages
5,598,455
Members
414,239
Latest member
xnanx

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
Top