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.

Buck_BeasomDatabase DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.
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.

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.

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook 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.

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.
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.

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.