ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Values don't behave when converting text to values in userform (https://www.excelbanter.com/excel-programming/383262-values-dont-behave-when-converting-text-values-userform.html)

Kragelund

Values don't behave when converting text to values in userform
 
VBA / Xl 2002

I use a userform to make the user input in a time registration form. The
format on the userform form side is .text. When saving this information to a
different sheet I try to convert the text to values by changing the suffix
from .text to .value. When the values are printed on the sheet, the comma
(used as a delimiter in Danish language instead of "." ) has been deleted.

Using the following code:
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"

and enter the value 1,23456 in the form, I get the output in the following
format
123.456

What can I do get the representation right? Thx in advance.


Private Sub GemClick_Click()
Dim i As Integer
Dim dato As Date

Worksheets("Timeseddel").Activate

Range(Cells(15, 3), Cells(31, 7)).ClearContents
Cells(7, 7).ClearContents
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"
ActiveWorkbook.Save

Cells(15, 3).Activate

With ActiveCell

If ChkAltDato = True Then
..Offset(-8, 4).Value = TxtAltDato.Text
Else: .Offset(-8, 4).Value = txtDato.Text
End If

.Offset(0, 0).Value = LstNavn1.Text
.Offset(0, 1).Value = TxtWkType1.Text
.Offset(0, 2).Value = TextRmk1.Text
.Offset(0, 3).Value = TextTimeDbt1.Value
.Offset(0, 4).Value = TextTimeNonDbt1.Value

.....

End Sub

Gary''s Student

Values don't behave when converting text to values in userform
 
Have you tried
Offset().Text=
instead of
Offset().Value=
--
Gary's Student
gsnu200706


"Kragelund" wrote:

VBA / Xl 2002

I use a userform to make the user input in a time registration form. The
format on the userform form side is .text. When saving this information to a
different sheet I try to convert the text to values by changing the suffix
from .text to .value. When the values are printed on the sheet, the comma
(used as a delimiter in Danish language instead of "." ) has been deleted.

Using the following code:
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"

and enter the value 1,23456 in the form, I get the output in the following
format
123.456

What can I do get the representation right? Thx in advance.


Private Sub GemClick_Click()
Dim i As Integer
Dim dato As Date

Worksheets("Timeseddel").Activate

Range(Cells(15, 3), Cells(31, 7)).ClearContents
Cells(7, 7).ClearContents
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"
ActiveWorkbook.Save

Cells(15, 3).Activate

With ActiveCell

If ChkAltDato = True Then
.Offset(-8, 4).Value = TxtAltDato.Text
Else: .Offset(-8, 4).Value = txtDato.Text
End If

.Offset(0, 0).Value = LstNavn1.Text
.Offset(0, 1).Value = TxtWkType1.Text
.Offset(0, 2).Value = TextRmk1.Text
.Offset(0, 3).Value = TextTimeDbt1.Value
.Offset(0, 4).Value = TextTimeNonDbt1.Value

....

End Sub


Kragelund

Values don't behave when converting text to values in userform
 
Yes, I did that at first. The result is that the number is formatted as text,
which means that I can sum up the rows in the destination sheet. That was the
first problem I was trying to get around by renaming the offset .value
instead of .text, but apparently with little succes.




"Gary''s Student" skrev:

Have you tried
Offset().Text=
instead of
Offset().Value=
--
Gary's Student
gsnu200706


"Kragelund" wrote:

VBA / Xl 2002

I use a userform to make the user input in a time registration form. The
format on the userform form side is .text. When saving this information to a
different sheet I try to convert the text to values by changing the suffix
from .text to .value. When the values are printed on the sheet, the comma
(used as a delimiter in Danish language instead of "." ) has been deleted.

Using the following code:
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"

and enter the value 1,23456 in the form, I get the output in the following
format
123.456

What can I do get the representation right? Thx in advance.


Private Sub GemClick_Click()
Dim i As Integer
Dim dato As Date

Worksheets("Timeseddel").Activate

Range(Cells(15, 3), Cells(31, 7)).ClearContents
Cells(7, 7).ClearContents
Range(Cells(15, 6), Cells(31, 7)).Select
Selection.NumberFormat = "0,0"
ActiveWorkbook.Save

Cells(15, 3).Activate

With ActiveCell

If ChkAltDato = True Then
.Offset(-8, 4).Value = TxtAltDato.Text
Else: .Offset(-8, 4).Value = txtDato.Text
End If

.Offset(0, 0).Value = LstNavn1.Text
.Offset(0, 1).Value = TxtWkType1.Text
.Offset(0, 2).Value = TextRmk1.Text
.Offset(0, 3).Value = TextTimeDbt1.Value
.Offset(0, 4).Value = TextTimeNonDbt1.Value

....

End Sub



All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com