0

I have a form that fills textbox with the value in a specific column on the active row. I have one problem, the column is numeric but has the character"-" for e.g 0000-00-000-000 I want the textbox to format as 0000000000000 when the form opens. I use the code below but it doesnt do anything

Private Sub UserForm_Initialize()
Dim r As Long

    r = ActiveCell.Row

    Me.TextBox1.value = Cells(r, 9).value
    TextBox1.Text = Format(TextBox1.Text, "0000000000000")
End Sub

1 Answer 1

1

replace is the function that will manipulate the string as required.

The simplest way would be to simply remove the dashes by replacing them with an empty string

TextBox1.Text = replace(TextBox1.Text,"-","")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.