MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Problem with cells format

Posted by Antonio on February 19, 2001 12:53 AM

Hello. I need some help from you.

I've done a VBA program to import data from a mdb file to an Excel file. I have a column in a sheet of numbers that represent money. I need to put all the cells in the column with a money format.
I've tried something like this:
activeworkbook.activesheet.cells(i,j)=format(exp, "#,###,###,##0")
But it doesn't properly work. I think it would be better to change the format of the entire column of cells after they are loaded, but I don't know how to program it, I can't find in the vba reference the correct method or property.
Could anybody help me, please?

Thank you very much.

Posted by Dave Hawley on February 19, 2001 1:10 AM

Hi Antonio

You are right in saying you are better off formatting the entire Column. This code will format Column A on the active sheet to a currenyy format.

Columns(1).NumberFormat = "$#,##0.00"

The best way to get the format you want is to record a macro formatting a cell with it.


OzGrid Business Applications