Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default validate phone number

hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default validate phone number

if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

"sarah" wrote in message
...
hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default validate phone number

thanks! :)

umm....but another probably question... :D

where do i put this code?? does it go in the macro or
something :S


-----Original Message-----
if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

"sarah" wrote in

message
...
hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default validate phone number

Think you missed an Else out after first endif?
-----Original Message-----
if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

"sarah" wrote in

message
...
hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default validate phone number

Your right

if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
Else
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

wrote in message
...
Think you missed an Else out after first endif?
-----Original Message-----
if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

"sarah" wrote in

message
...
hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default validate phone number

It depends on when you want it to work and where you want it to work. I
have no way of knowing what you are doing.

Do you want it to run when a person enters a number in a cell in a specific
column. then you would use the change event
Right click on the sheet tab and select view code

in the module, at the top select worksheet and change

Private Sub Worksheet_Change(ByVal Target As Range)
if target.count 1 then exit sub
if Target.column = 4 then
if Len(Target.Value) = 10 then
if isnumeric(Target.Value) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
Else
msgbox "Must be 10 digits"
End if
End Sub

--
Regards,
Tom Ogilvy

"sarah" wrote in message
...
thanks! :)

umm....but another probably question... :D

where do i put this code?? does it go in the macro or
something :S


-----Original Message-----
if Len(ActiveCell) = 10 then
if isnumeric(activeCell) then
activecell.Numberformat:="(###) ###-####"
else
msgbox "Must be a number"
end if
msgbox "Must be 10 digits"
End if

--
Regards,
Tom Ogilvy

"sarah" wrote in

message
...
hi,

how can i make sure the user enters a phone number.

i know u can go to formatcellsgeneral and select
specialphone number

BUT.. this only formats it to a phone number. how do I
ensure the user enters in only 10 digits?? and then also
put it in the nice 'phone number' format (###) ###-####

Help! :)



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Phone number not nrodADAA Excel Discussion (Misc queries) 2 September 4th 07 09:42 PM
Validate Whole Number Series with Exclusions QLT1120 Excel Discussion (Misc queries) 2 September 18th 06 07:41 PM
validate phone numbers etc. John New Users to Excel 1 July 11th 06 02:36 AM
? Link attached - How to validate SIN (Social Insurance Number) [email protected] Excel Worksheet Functions 5 December 17th 05 07:07 AM
Phone number Lisa Excel Discussion (Misc queries) 3 May 10th 05 10:34 PM


All times are GMT +1. The time now is 02:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"