kapela2017
New Member
- Joined
- Oct 16, 2022
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
In accordance with what is indicated in Rule # 13 of the forum, I will limit the following
Link
Post details
Greetings seniors, I've been trying for a while to get a text box to behave in a specific way, which I'll try to briefly describe, I need the values to be entered from right to left, like on a calculator and the format should have "Kg" concatenated either It must be necessary to enter the comma because it is automatically positioned, I attach the Work Code in the Two textboxes can be seen But this must be done in a single textbox without the need to have another text box as an auxiliary, I get the impression that this will be easier with a Udf, but I remain attentive to your suggestions
Link
Input in textbox from right to left with comma positioning
Greetings code warriors, I will try to be as explicit as possible, for months I have been struggling with a code without success, I am trying to create a textbox code that allows me to enter the digits from right to left, and in the second digit place a comma automatically concatenated with the...
www.excelforum.com
Post details
Greetings seniors, I've been trying for a while to get a text box to behave in a specific way, which I'll try to briefly describe, I need the values to be entered from right to left, like on a calculator and the format should have "Kg" concatenated either It must be necessary to enter the comma because it is automatically positioned, I attach the Work Code in the Two textboxes can be seen But this must be done in a single textbox without the need to have another text box as an auxiliary, I get the impression that this will be easier with a Udf, but I remain attentive to your suggestions
VBA Code:
Option Explicit
Dim PreviousValue As String
Dim ProgramChange As Boolean
Private Sub TextBoxDataEntry_Change()
Dim FormattedNumber As String
If ProgramChange Then Exit Sub
If TextBoxDataEntry = "" Then
TextBoxDataDisplay = ""
ElseIf Not IsNumeric(TextBoxDataEntry) Then
MsgBox "Entry must be numeric"
ProgramChange = True
TextBoxDataEntry = PreviousValue
ProgramChange = False
ElseIf CLng(TextBoxDataEntry) > 9999 Then
MsgBox "Entry must be numeric 0 - 9999"
ProgramChange = True
TextBoxDataEntry = PreviousValue
ProgramChange = False
Else
FormattedNumber = Format(TextBoxDataEntry, "0000")
TextBoxDataDisplay = Left(FormattedNumber, 2) & "," & Right(FormattedNumber, 2) & " Kg"
PreviousValue = TextBoxDataEntry
End If
End Sub