开发者

MS Access VBA Format Excel Sheet Column as Currency

In the below 开发者_JAVA技巧code, I need to format column E & F starting with row(3) as a currency. Thanks!

            Set objApp = CreateObject("Excel.Application")

            objApp.Visible = True
            Set wb = objApp.Workbooks.Open("template.xls", True, False)
            wb.Sheets(1).Rows(3).Delete
            wb.Sheets(1).Range("A1").Value = title
            'need to format column E & F as currency

            Set objApp = Nothing


Range("E:F").NumberFormat = "$#,##0.00"

or

Range("E:F").SpecialCells(xlCellTypeFormulas).NumberFormat = "$#,##0.00"

or

Range("E:F").SpecialCells(xlCellTypeConstants).NumberFormat = "$#,##0.00"


If you only want to format 2 cells, it's one line:

wb.Sheets(1).Range("E3:F3").NumberFormat = "$#,##0.00"

If you want to format all cells below row 3, and assuming those cells aren't already populated, then you could use:

Range("E3:F3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.NumberFormat = "$#,##0.00"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜