Setting Range.NumbeFormat(Local) on non-English Office installations

rdilipk

New Member
Joined
Nov 17, 2011
Messages
36
<code>On this page:
http://msdn.microsoft.com/en-us/library/aa224873(v=office.11).aspx


The example for NumberFormat goes like this:


Worksheets("Sheet1").Range("A17").NumberFormat = "General"


However the string "General" seems incorrect when you have installed a non-English Microsoft Office version. That line above fails by raising an exception.


What is the correct way to set this property in a language-agnostic fashion?


Note: I am interested only in setting that one particular value
</code>
 
<CODE>On this page:
http://msdn.microsoft.com/en-us/library/aa224873(v=office.11).aspx


The example for NumberFormat goes like this:


Worksheets("Sheet1").Range("A17").NumberFormat = "General"


However the string "General" seems incorrect when you have installed a non-English Microsoft Office version. That line above fails by raising an exception.


What is the correct way to set this property in a language-agnostic fashion?


Note: I am interested only in setting that one particular value
</CODE>


It worked perfectly in my Excel 2007 portuguese version.

Let me ask: is there in the Workbook a sheet named Sheet1?

M.
 
Upvote 0
It worked perfectly in my Excel 2007 portuguese version.

Let me ask: is there in the Workbook a sheet named Sheet1?

M.

I just copied that line from the MSDN site. My actual code has a properly constructed range object. I do:

Range.NumberFormat = "General"

This fails on a Chinese language Office installation. (unable to set NumberFormat property or something like that)
 
Upvote 0
I just copied that line from the MSDN site. My actual code has a properly constructed range object. I do:

Range.NumberFormat = "General"

This fails on a Chinese language Office installation. (unable to set NumberFormat property or something like that)

Try

Range("A1").NumberFormat = "General"

M.
 
Upvote 0
Assuming every cell on the entire sheet has not been formatted differently from General, you could just let VB figure it out for you automatically...

Code:
Range("A1").NumberFormat = Cells(Rows.Count, Columns.Count).NumberFormat
 
Upvote 0
Try

Range("A1").NumberFormat = "General"

M.

I think I simplified my example too much. By Range.NumberFormat I simply meant that I have a properly constructed range object on which I call the NumberFormat property.

anyway, I found a solution to my problem. The correct way to do it in a language-agnostic way is to use the return value from:

Application.International(xlGeneralFormatName)

Thanks to:
http://www.excelforum.com/excel-pro...cel-2010-ticklabels-numberformat-problem.html
 
Upvote 0

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