Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Formatting numbers

Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do FormatSpecialPhone
Numbers.
How to do that programmatically?
Thanks,
Fred


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formatting numbers

Not sure how you want to implement this, but the following should give you
an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Formatting numbers

Thank you, Rick
When I try this:
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"
there is a compile error:
"Expected: identifier or bracketed expression"

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?
Thanks,
Fred

"Rick Rothstein" wrote in message
...
Not sure how you want to implement this, but the following should give you
an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Formatting numbers

Sorry, my fault. Syntax error.
When I try this:
moExcelWS.Cells(3,3).NumberFormat = "[<=9999999]###-####;(###) ###-####"
the response is (True/False) which indicates to me that it is comparing the
formats not introducing it.
Fred

"fred" wrote in message
...
Thank you, Rick
When I try this:
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"
there is a compile error:
"Expected: identifier or bracketed expression"

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?
Thanks,
Fred

"Rick Rothstein" wrote in message
...
Not sure how you want to implement this, but the following should give
you an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formatting numbers

moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"

First off, I assume the missing "dot" that should be in front of
"NumberFormat" is a typo. What is moExcelWS... a variable containing the
worksheet name or a variable containing a reference to the worksheet? If the
former, you would need to make it an argument to the Worksheet object
call...

Worksheets(moExcelWS).Cells(3,3).NumberFormat=.... etc

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?


Do you mean in code (as opposed to selecting the column and using
Cell/Format on the worksheet directly)? If so, you should be able to do
something like this in code...

Columns("G").NumberFormat = "[<=9999999]###-####;(###) ###-####"

Where you would change the column reference to suit your needs and preface
it with a worksheet reference.

--
Rick (MVP - Excel)


"fred" wrote in message
...
Thank you, Rick
When I try this:
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"
there is a compile error:
"Expected: identifier or bracketed expression"

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?
Thanks,
Fred

"Rick Rothstein" wrote in message
...
Not sure how you want to implement this, but the following should give
you an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formatting numbers

I'm not sure what you mean by "the response". If you execute that line, as
written, it should perform the format operation... if you include as part of
a larger line of code, well, then I'd have to see exactly how you are trying
to use it in order to make a guess at what is happening.

--
Rick (MVP - Excel)


"fred" wrote in message
...
Sorry, my fault. Syntax error.
When I try this:
moExcelWS.Cells(3,3).NumberFormat = "[<=9999999]###-####;(###) ###-####"
the response is (True/False) which indicates to me that it is comparing
the formats not introducing it.
Fred

"fred" wrote in message
...
Thank you, Rick
When I try this:
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"
there is a compile error:
"Expected: identifier or bracketed expression"

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?
Thanks,
Fred

"Rick Rothstein" wrote in message
...
Not sure how you want to implement this, but the following should give
you an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format
all numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Formatting numbers

Thank you, Rick
moExcelWS.Columns("c").NumberFormat = "[<=9999999]###-####;(###) ###-####"
does work!
It formats all values in that column.
Fred

"Rick Rothstein" wrote in message
...
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"


First off, I assume the missing "dot" that should be in front of
"NumberFormat" is a typo. What is moExcelWS... a variable containing the
worksheet name or a variable containing a reference to the worksheet? If
the former, you would need to make it an argument to the Worksheet object
call...

Worksheets(moExcelWS).Cells(3,3).NumberFormat=.... etc

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?


Do you mean in code (as opposed to selecting the column and using
Cell/Format on the worksheet directly)? If so, you should be able to do
something like this in code...

Columns("G").NumberFormat = "[<=9999999]###-####;(###) ###-####"

Where you would change the column reference to suit your needs and preface
it with a worksheet reference.

--
Rick (MVP - Excel)


"fred" wrote in message
...
Thank you, Rick
When I try this:
moExcelWS.Cells.(3,3)NumberFormat="[<=9999999]###-####;(###) ###-####"
there is a compile error:
"Expected: identifier or bracketed expression"

I wonder, if there is way to "preformat" the whole column, so when the
numbers are entered into it they will be automatically formatted as the
phone numbers?
Thanks,
Fred

"Rick Rothstein" wrote in message
...
Not sure how you want to implement this, but the following should give
you an idea how to proceed...

Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"

--
Rick (MVP - Excel)


"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format
all numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Formatting numbers

One more question:
I am loading very long list of numbers, (one column, loading in the loop row
by row).
For the optimum speed:
should I preformat the column before loading the numbers or format the whole
column after the loading is done?
What do you recommend?
Thanks,
Fred

"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formatting numbers

I've never really thought about it... my gut feeling says it probably
doesn't matter which order you do those in.

--
Rick (MVP - Excel)


"fred" wrote in message
...
One more question:
I am loading very long list of numbers, (one column, loading in the loop
row by row).
For the optimum speed:
should I preformat the column before loading the numbers or format the
whole column after the loading is done?
What do you recommend?
Thanks,
Fred

"fred" wrote in message
...
Hello,
When using Excel automation, how to programmatically format all
numbers in the specified column as the phone numbers.
I can see it in the Excel menu there is possible to do
FormatSpecialPhone Numbers.
How to do that programmatically?
Thanks,
Fred




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
formatting numbers as 1st 2nd Bob Arnett Excel Worksheet Functions 16 March 30th 18 06:23 AM
Formatting numbers tehya Excel Worksheet Functions 5 July 6th 06 01:13 AM
formatting numbers Pascale Excel Discussion (Misc queries) 2 January 24th 06 11:05 AM
formatting numbers Paula[_4_] Excel Programming 2 May 18th 05 06:40 AM
formatting numbers jonas Excel Worksheet Functions 3 February 16th 05 06:12 PM


All times are GMT +1. The time now is 06:58 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"