+ Reply to Thread
Results 1 to 3 of 3

Number Format Macro Not Working Properly

  1. #1
    Registered User
    Join Date
    02-07-2022
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    2

    Number Format Macro Not Working Properly

    I like a number format for negative numbers that is red has brackets around it. I created a simple macro so I can easily do this on every spreadsheet but I can’t get it to work properly. Macro is below.

    Sub MyNumberFormat()
    '
    ' MyNumberFormat Macro
    '
    ' Keyboard Shortcut: Ctrl+n
    '
    Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
    End Sub

    When you run it, there are no brackets. The format that it creates is #,##0.00;[Red]-#,##0.00 so it has dropped the brackets.

    If you amend the macro to Selection.NumberFormat = "#,##0.00_);[Red](###0.00)" this works fine, it creates the brackets but of course I’ve dropped the comma so I still need to go into the format and edit it so I have a comma separating the thousands.

    Any idea why the macro won’t set the format correctly?

    Many thanks

    Stuart

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,901

    Re: Number Format Macro Not Working Properly

    Try adding in the format for 0:

    Please Login or Register  to view this content.
    Rory

  3. #3
    Registered User
    Join Date
    02-07-2022
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    2

    Re: Number Format Macro Not Working Properly

    Brilliant. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Conditional Format not working properly
    By jme1013 in forum Excel General
    Replies: 11
    Last Post: 04-11-2018, 05:32 AM
  2. Macro is not Working Properly
    By joao1232 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2016, 05:53 PM
  3. Macro not working properly as add-in
    By TZ Saic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-03-2015, 07:54 AM
  4. macro not working properly
    By cooner3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2014, 10:16 AM
  5. [SOLVED] Macro not working properly for conversion of date format
    By abraham30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2014, 10:46 AM
  6. Macro isn't working properly.
    By EAgerton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2014, 01:14 AM
  7. Macro Not Working Properly
    By fasrose in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2013, 04:49 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1