Formatting Label Box for Phone Numbers (###) ###-####

glynnmack

New Member
Joined
May 27, 2011
Messages
3
Using excel cell formatting, I've entered hundreds of vendors and their phone numbers into a spreadsheet.

I designed a macro to search the spreadsheet and put the results in a user form, with their names to be selected in a list box, and their phone numbers displayed in a label box.

Unfortunately, I can't figure out how to format the label box to get the phone number in the standard (###) ###-#### form (I typed them in without formatting at the time, letting the excel formatting do that for me).

It seems I should be able to use visual basic to do this, but I'm at a loss.

Private Sub LastNameListBox_Click()

Dim selectedRow As Long
selectedRow = LastNameListBox.ListIndex + 1
SelectedMainPhone = vendorData(selectedRow, 6)
MainPhone.Caption = SelectedMainPhone

Any help would be greatly appreciated.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Use

Code:
[FONT=Courier New]MainPhone.Caption = Format(SelectedMainPhone[COLOR=black], "(&&&)&&&-&&&&")[/COLOR][/FONT]
 
Upvote 0
If you need the format altered just use the VBA format function, e.g.

Label1.Caption = Format(1111111111, "(###) ###-####")
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

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