Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Formatting a cell to Currency (w/ 0 Decimal Places) in VBA

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi All,

    I need to save a value into a certain cell, formatting it as currency with 0 decimal places. How do I do this?

    I know of the Format function, but don't know how to control the decimal places.

    -
    Activesheet.Cells(1,2) = Format(ListPrice,"currency")
    -

    I cannot pre-format the cell using the Excel menu because my code requires all cells in the worksheet to be Cleared (Using "Clear All") before this statement. I'd really applreciate any help on this. Thanks!

    Manish

  2. #2
    Board Regular Corticus's Avatar
    Join Date
    Apr 2002
    Location
    Sarasota, FL
    Posts
    1,579
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    try adding this code to the worksheet:
    Sub Workbook_Open()


    Sub Workbook_Open()

    Cells.Select
    Selection.NumberFormat = "#,##0"
    Range("A1").Select
    Application.CalculateFull
    End Sub

    and if you need a symbol, substitute this in:

    Selection.NumberFormat = "$#,##0"

    -Corticus

  3. #3
    Board Regular Barry Katcher's Avatar
    Join Date
    Feb 2002
    Location
    Dog Beach, Florida. Yeaahh!
    Posts
    4,053
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can get the code Corticus sent you, and much, much more, by recording a keyboard macro.

    Click on Tools-Macro-Record New Macro-O.K.
    Click on Format-Cells-Number-Currency and set the decimal place to zero.
    Click on Tools-Macro-Stop Recording.

    Walla, mansewer!
    Barry-

    Photo Restoration/Enhancement

    http://www.smiledogproductions.com
    click below for detour


Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •