Userform does not show leading 0 for telephone number

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I am using the following code for a Textbox on my userform.

All works fine apart from say im looking for a number 07899

It has pulled in a telephone number that has a leading 0 missing.
Looking on the worksheet 0 is shown & formatted a custom.
The numbers that have a leading 0 are also formatted as custom & 0 is also shown on worksheet

Rich (BB code):
Private Sub TextBoxTelephone_Change()
Me.Label1.Visible = False
Me.Label2.Visible = False
Me.Label3.Visible = False
Me.Label4.Visible = False
TextBoxTelephone = UCase(TextBoxTelephone)
  Dim r As Range, f As Range, cell As String, added As Boolean
  Dim sh As Worksheet
  
  Set sh = Sheets("DATABASE")
  sh.Select
  With ListBox1
    .Clear
    .ColumnCount = 4
    .ColumnWidths = "200;180;260;10"
   If TextBoxTelephone.Value = "" Then Exit Sub
    Set r = Range("W5", Range("W" & Rows.Count).End(xlUp))
    Set f = r.Find(TextBoxTelephone.Value, LookIn:=xlValues, LookAt:=xlPart)
    If Not f Is Nothing Then
      cell = f.Address
      Do
        added = False
        For i = 0 To .ListCount - 1
          Select Case StrComp(.List(i), f.Value, vbTextCompare)
            Case 0, 1
              .AddItem f.Value, i
              .List(i, 1) = f.Offset(, -19).Value
              .List(i, 2) = f.Offset(, -22).Value
              .List(i, 3) = f.Row
              added = True
              Exit For
          End Select
        Next
        If added = False Then
          .AddItem f.Value
          .List(.ListCount - 1, 1) = f.Offset(, -19).Value
          .List(.ListCount - 1, 2) = f.Offset(, -22).Value
          .List(.ListCount - 1, 3) = f.Row
        End If
        Set f = r.FindNext(f)
      Loop While Not f Is Nothing And f.Address <> cell
      TextBoxSearch = UCase(TextBoxSearch)
      .TopIndex = 0
    Else
      MsgBox "NO SUCH TEL NUMBER FOUND", vbCritical, "POSTAGE SHEET CUSTOMER TEL NUMBER SEARCH"
      TextBoxTelephone.Value = ""
      TextBoxTelephone.SetFocus
    End If
  End With
End Sub
 

Attachments

  • EaseUS_2024_04_ 8_15_06_14.jpg
    EaseUS_2024_04_ 8_15_06_14.jpg
    29.3 KB · Views: 27

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
On my worksheet in column W i see all the phone numbers.
All start with 0
I click on one & in address bar i see that the 0 isnt shown.
All my telephone numbers are formatted as screenshot show with all the 0000

So i find a number that shows 0 on worksheet BUT where the 0 is missing in address bar.
I simply just re enter the phone number in the cell basically overwriting it & hey presto 0 is now shown in address bar.

My issue is can we write some code etc to do this for me as there are say 200 + of them
 

Attachments

  • EaseUS_2024_04_ 8_15_27_34.jpg
    EaseUS_2024_04_ 8_15_27_34.jpg
    45.1 KB · Views: 20
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,111
Members
453,021
Latest member
Justyna P

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