Need To Format a Excel Worksheet Cell from VB.NET Code

Cognize
Cognize used Ask the Experts™
on
Hi I'm using com objects to format cells in an excel sheet from VB.NET code.

I've got code for simple formatting like so:

EX.Document.worksheets(1).Range("A1:A1000").Font.Bold = True


I need to be able to specify that cells in a certain range should be left padded with zeros where they are less than 4 characters long.

Psuedo Code:

EX.Document.worksheets(1).Range("A1:A1000").Format(Lpad('0',4))

Does such functionality exist to do this??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
What you want is this:

.NumberFormat = "0000"

You'll get:

1 as 0001
12 as 0012
123 as 0123
1234 as 1234
12345 as 12345


Author

Commented:
Cheers fella, that's the one.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial