VBA Excel : Show the zero in left on mobile number

282 views Asked by At

I'm working on a project with VBA Excel, and I have a problem with mobile number. When I insert the mobile number for example : 0762....... on excel we can see just 762...... without zero on the left. How can I do that ?

This is a part of my script :

 If MsgBox("Confirmez-vous l’insertion de ce nouveau contact ?", vbYesNo, "Demande de confirmation d’ajout") = vbYes Then

    i = WorksheetFunction.CountA(Range("A:A")) + 1 'Pour placer le nouvel enregistrement à la première ligne de tableau non vide

    MsgBox i

    Sheets("Reservations").Range("A" & i).Value = UserForm1.TextBox1.Value

    Sheets("Reservations").Range("B" & i).Value = UserForm1.TextBox2.Value

    Sheets("Reservations").Range("C" & i).Value = UserForm1.TextBox3.Value

    Sheets("Reservations").Range("D" & i).Value = UserForm1.TextBox4.Value

    Sheets("Reservations").Range("E" & i).Value = UserForm1.TextBox5.Value

    Sheets("Reservations").Range("H" & i).Value = UserForm1.TextBox8.Value

    Sheets("Reservations").Range("F" & i).Value = UserForm1.ComboBox4.Value

    Sheets("Reservations").Range("G" & i).Value = UserForm1.ComboBox1.Value

    Sheets("Reservations").Range("G" & i).Value = UserForm1.ComboBox2.Value

    Sheets("Reservations").Range("I" & i).Value = UserForm1.TextBox9.Value




End If

Thank you.

1

There are 1 answers

0
Kerry White On BEST ANSWER

You need to run a format on the cells like this:

Sheets("Reservations").Range("I" & i).NumberFormat = "00 00 00 00 00"