Using VB to format Excel cells

  • Thread starter Thread starter Ed
  • Start date Start date
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?
 
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)
 
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.
 
Good chance that they are being stored as Text. If so, you can't currency
format text.
 
Back
Top