Excel Formatting from VB

I've got my application to build a spreadsheet, but now I want to make that spreadsheet look good. I need to adjust cell alignments, font face size and weight, row height, column width, set borders, freeze a pane at the top, and protect the whole sheet. How is this done? Where do I find help references for Excel.Application methods and properties?
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.

This will do the formatting for the cells in range B6 to I16
(probably cou can also change the rest like this way)

.Range("B6:I16").NumberFormat = "#0.00"
.Range("B6:I16").FontColor = vbRed (can also be color or textcolor)

Personally I found the built-in help for ExcelVBA quite helpful.

Since your application already builds the spreadsheet, I assume that you have a reference to the Excel Object Library in your project.
Just press F2 to show the object catalogue, select the Excel Library and look for a class called "Range". That shows you all properties, methods and events the range-object has. By pressing F1 VB should show you help to the command you've selected.
You can find help on the application, workbook and worksheet object just the same way.

Another way of finding the right properties would be to use Excel and record a macro while you do the changes manually. The you can enter the VBA-Editor (F11) and have a look at the generated code and pick the lines you want.

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
For information on Excel.Application, start here:


And for more specific information, search http://msdn.microsoft.com

With regards to formatting your sheet, the easiest way to let Excel do the work for you:

1) Open an Excel sheet
2) Start recording a macro (Tools -> Macros)
3) Perform the formatting you want to know how to do
4) Stop the macro recording

Now, check the source code of the macro in Excel's Visual Basic Editor (Tools -> Macros -> Visual Basic Editor) - most of the code you need will already be in there, you just need to adapt it to work with the Excel.Application object.

ThanborAuthor Commented:
Thx a lot. Very helpful.
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
Visual Basic Classic

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.