Format Excel Columns in Accounting Format

I'm populating Excel from Access VBA and want to format columns in the Accounting format. I'm using late binding, so ".Style "Comma" does not work, but when I tried "0,000.00" it gives me zeroes for blank values. I just want the accounting format.

Thanks.
Buck_BeasomDatabase DesignerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dsackerContract ERP Admin/ConsultantCommented:
Try:  #,##0.00_;(#,##0.00);""

The two double quotes at the end are for when a number is zero. The one in the middle is for when a number is negative.

You can use zeroes instead of pound signs, if you wish.
0
Buck_BeasomDatabase DesignerAuthor Commented:
I tried this:

objExcel.Selection.NumberFormat "#,##0.00_;(#,##0.00);"""

and got the error "NumberFormat of Range Class failed. So obviously I need to call the format some other way.

Thanks.
0
dsackerContract ERP Admin/ConsultantCommented:
You'll need two double-quotes to represent one double-quote. Try it this way:

objExcel.Selection.NumberFormat = "#,##0.00_);(#,##0.00);"""";"
Gotta have the equal sign (=), too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Buck_BeasomDatabase DesignerAuthor Commented:
Tried this, and the formatting seems to work, but a VERY weird thing happens. There is a heading in each column, white letters on blue. After the format step runs for the column, the heading becomes invisible. When I select the cell, the heading is still there, but I have to reformat the cell to General for it to become visible again.

Thoughts?
0
dsackerContract ERP Admin/ConsultantCommented:
Don't know if that is a product of some earlier testing. I recommend to not include any headings in the selection. And if necessary, clear all formatting before applying these number formats.
0
Buck_BeasomDatabase DesignerAuthor Commented:
Then I have to select a million plus rows instead of just selecting the column. Instead, I will just re-select the top row at the end and reformat it to general. That will make all the column headings justify left anyway, which will be neater.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.