Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Format Cells as an Accounting Number in Excel Number Formatting


Bookmark and Share

This free Excel macro formats a selected cell as an Accounting number. This means that the accounting number format is applied to any cells that have been selected when this macro is run. This format puts a dollar sign in the left and by default adds two decimal places to the number. This format is meant to display money.

This is a great piece of code to include by itself or in a larger macro in order to speed up formatting in Excel.
Where to install the macro:  Module

Excel Macro to Format Cells as an Accounting Number in Excel Number Formatting

Sub Format_Cell_Accounting()

Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"

End Sub


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Excel 2007 Vb Accounting Number Format - Excel

View Content
I am using this code to set positive values in a desired range to negative values, however the accounting number format within my table does not carry to a new row, it is set to Currency. I would like to know how to add the accounting number format code into this code.

cell.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* " - "??_);_(@_)"



Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H100"
Dim cell As Range
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
If Not (Target = 0) Then
If Left(cell.Value, 1) "-" Then
cell.Value = cell.Value * -1
End If
End If
Next cell
End If
ws_exit:
Application.EnableEvents = True
End Sub

First Number Cut In Half In Excel 2010 Accounting Format - Excel

View Content
I can't figure this one out (Excel 2010). On any cell that has accounting format the first number of the value only displays the right side of the number. Almost as if the number is cut in half. If I change the format to currency this does not happen.

Every Number Turned To Accounting Format - Excel

View Content
I am working with a macro-enabled workbook that contains many sheets and all of a sudden every number figure is converted to the accounting format. Filters that contain numbers are now $2.00 instead of just '2' so i am not even able to run my macro. I definitely didn't highlight all of these cells on all sheets and select the accounting format. Anyone ever had this issue and know of a solution. Thanks.

Format As Number Or Accounting With If Statement - Excel

View Content
I would like to format a cell with a number being divided by 1,000 as either "number" or "accounting" depending on if the result is actually "0" or less than 1,000 (where it would display "0" instead of "-")

Conditional Formatting A Cells Number Format - Excel

View Content
In Excel 2007, I have a cell in Sheet1 with the named range of "currency" and data validation set to list, with currency symbols listed in the drop down. On Sheet1 I used conditional formatting to change the number format of certain cells to match the currency symbol selected in the drop down list using,for example, =currency="$" and it works fine. On Sheet2 I use the same conditional format statement and when I select a currency from the drop down on Sheet1 it will change the format once but if I select a different currency it won't change the number format. What's weird, is if not only do I set the conditional formatting to change the number format but the color of the cell as well, the cell color will change but the number format will not. Is this just a bug in excel or am I doing something wrong?

Thanks

Conditional Formatting In Excel 2003 For Only Cell Format Number - Excel

View Content
Hello,

I am running Excel 2003 and I wish to apply conditional formatting to only cells with format Number. Does anyone knows an easy way of doing this or a VBA code for it?

I have tried on my own to write a code , but as I am new to VBA , I can't figure out how to make it work . The code supposed to compare all the numeric values from an uknown number of columns with numeric values from column B row by row and Bold the ones greater. The number of columns and rows is uknown because the data will be exported from another software to Excel , so bassically I wish to format a woorkbook to automatically do that.
The code is below:

VB:

Sub ConvertsFontStyletoBold() 
     
    Dim Count As Integer 
    Dim Count1 As Integer 
    Dim nr1 As Range 
    Dim nr2 As Range 
    Dim nr3 As Range 
    Dim nr4 As Range 
    Dim nr5 As Range 
    Dim nr6 As Range 
    Dim nr7 As Range 
    Dim nr8 As Range 
     
     
    Set nr1 = Range("A65536").End(xlUp) 
    nr1.Select 
    Set nr2 = Range("a1").End(xlToRight) 
    nr2.Select 
    Count = Range("A1", nr2).Columns.Count - 1 
    Set nr3 = Range("A1", nr1.Offset(0, Count)) 
    nr3.Name = "Data" 
    nr3.Select 
    Set nr4 = Range("B65536").End(xlUp) 
    nr4.Select 
    Set nr5 = Range("B7", nr4) 
    nr5.Select 
    Set nr6 = Range("D7").End(xlToRight) 
    nr6.Select 
    Set nr7 = Range("D65536").End(xlUp) 
    nr7.Select 
    Count = Range("D7", nr6).Columns.Count - 1 
    Set nr8 = Range("D7", nr7.Offset(0, Count)) 
    nr8.Name = "Values" 
    nr8.Select 
     
    For Each r In nr8.Rows 
        i = r.Row 
        r.Select 
        If IsNumeric(Cells(r)) = True And r.xlCellValue > nr5.xlCellValue = True Then 
            cell.Font.Bold = True 
        End If 
         
    Next r 
     
End Sub 


If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines




Thank you very much for any help received.

How To Change The Number Format From Number To Text Format With Decimal Values - Excel

View Content
Hi,

I need a macro which will help me in changing the format of a cell containing Number to Text Format without change in Decimal Values.

i.e for eg . in a Cell if we use some formula & get some numeric value let say 10000.00. Now i have to remove formula & I have to retain only value but the format should be "TEXT" i.e 10000.00 only.

I tried doing it maually but when i do this i am getting value as 10000 not 10000.00 .
102.10 is displayed as 102.1 --- 1002.50 as 1002.5---- 1002.00 as 1002 etc

i,e decimals r not displayed

I want the value with two decimals .ie 102.03 , 1001.01 etc.

Please assist me

Accounting Style Number Button - Excel

View Content
I use the accounting style under format - cell a lot. Can I add a button on
my toolbar for that?
Thanks


How Do Retain Formatting For Date Vs Number Format - Excel

View Content
I have a spreadsheet that has a bunch of Dates and Times that I am trying to import into my CRM Software. I can use excel. The problem is that the format that the start time and end time need to look like this:
5/1/2010 10:30 PM. Could also look like this 5/1/2010 22:30.
Problem is that the dates are in one column and the times are in another. I know I can put them together buy writing a formula C1=A1&" "&B1, but when I do it turns into the following: 40299 10:30 PM.

How does one stop it from converting the date part into this numeric formatting?

Thanks,

Make Number Formatting Real, Not Just Format - Excel

View Content
hi

i have a series of 10 digit numbers which I want to turn into a string of numbers each 2 digits long with some character in between. I figured out how to do it with number formatting (00-00-00-00-00) BUT the real reason I need it is because I want to do an extensive FIND and REPLACE but it won't recognise the formatting, only the original value...

any ideas about how to be able to apply this sort of pattern to the number...?

Random Tutorials
FV() Find the Future Value of Cash Today
         -Savings/Retirement Plan Calculations

(Intermediate)
Lookups With MATCH() and INDEX() Functions
(Intermediate)
Function and Formulas Lookup in Excel
(Easy)
Link Cells Between Worksheets
(Easy)
Consolidate & Combine Data from Separate Worksheets or Workbooks(Excel Files)
(Intermediate)
Assign Keyboard Shortcuts to Macros
(Easy)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com