Using VB to format Excel cells

E

Ed

I have a co-worker who is extracting data from SQL Server,
and using VB to create a spreadsheet. Everything is
working fine, except for the fact that he can't seem to
get the CURRENCY values to format within the spreadsheet.
He can get them to appear as numbers, with decimals but
not in CURRENCY format. Any ideas?
 
B

Bob Phillips

xlApp.ActiveWorkbok.Activesheet.Range("A1").Style = "Currency"

you may have other objects that point to the book/sheet/range, so just
adjust to suit.
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
A

Alex A

Try formatting the columns that the data appears in or
you could use a range as your selection. Here modify the
columns to your need or change the selection to a range:

Columns("D:p").Select
Selection.NumberFormat = "$#,##0"

Regards,
Alex.
 
T

Tom Ogilvy

Good chance that they are being stored as Text. If so, you can't currency
format text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top