textbox space number problem

kingman29

Board Regular
Joined
Jun 22, 2021
Messages
50
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone
I have in My Worksheet an UserForm contain Validation Button, and textbox for copy the written value in excel cell
So my problem is when I Click validate
the transfert of textbox value in cell, is with space
the code is
Sheets("Sheet1".Cells(i, 13) = TextBox10

and
Private Sub TextBox10_AfterUpdate()
On Error Resume Next
Dim Price As Double
Price = CCur(TextBox10)
TextBox10.Value = Format(Price, "Standard")

End Sub

So when I write on TextBox the value with be in this format : 1 234 456,10
but when I click on Validation button ,
the value past in excel sheets with spaces
So how Can we solve this problem ?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
There is an error in this line:
VBA Code:
Sheets("Sheet1".Cells(i, 13) = TextBox10
It should be:
VBA Code:
Sheets("Sheet1").Cells(i, 13) = TextBox10
I assume that is just a typo.

Can you give us an example?
- What are you typing into the Text Box?
- What is it returning?
- What do you want it to look like?
Please show us all three of those things.
 
Upvote 0
There is an error in this line:
VBA Code:
Sheets("Sheet1".Cells(i, 13) = TextBox10
It should be:
VBA Code:
Sheets("Sheet1").Cells(i, 13) = TextBox10
I assume that is just a typo.

Can you give us an example?
- What are you typing into the Text Box?
- What is it returning?
- What do you want it to look like?
Please show us all three of those things.
I write this 123456.60
after moving from the textbox the number become like this 123 456.0
in the Cell (1. 13), it will like 123 456.0 (with space between 123 456)
so you want to multiple celle (1 .13) * 2 = it will give an error because of the space
 
Upvote 0
There is an error in this line:
VBA Code:
Sheets("Sheet1".Cells(i, 13) = TextBox10
It should be:
VBA Code:
Sheets("Sheet1").Cells(i, 13) = TextBox10
I assume that is just a typo.

Can you give us an example?
- What are you typing into the Text Box?
- What is it returning?
- What do you want it to look like?
Please show us all three of those things.
So I found this solution
1- Change the Decimal in the windows parameter from "," to "."
2- add this code on Userform Code:
VBA Code:
Private Sub TextBox10_AfterUpdate()
On Error Resume Next
Dim Price As Double
Price = CCur(TextBox10)
TextBox10.Value = Format(Price, "Standard")
3- change this line
Sheets("Sheet1".Cells(i, 13) = TextBox10
to
Sheets("Sheet1".Cells(i, 13) = Format(TextBox10.Value, "Fixed")

and it's done
 
Upvote 0
Solution
Glad you figured it out. Your last post was a bit confusing, as I think you had another typo, as you appear to have lost a "6" in there.
No I just gave to my friend (you and the users in the forum) an exemple that I want to write a number 123 456.60 or 987 645.90 any number with a decimal
 
Upvote 0

Forum statistics

Threads
1,215,743
Messages
6,126,609
Members
449,321
Latest member
syzer

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