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

Thread: custom number format alignment

  1. #1
    Board Regular
    Join Date
    May 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    does anyone know if it's possible to make a custom number format which would right align positive and negative numbers, but center zeros and text? thx.

  2. #2
    MrExcel MVP Tom Urtis's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, California USA
    Posts
    11,162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can probably do it using VBA such as with the example below. Right click on your sheet tab, left click on View Code, and paste this in. Modify for range of interest.

    You did not specify if your data is manually entered, or if it appears in cells as the result of a formula, or if you already have the data in thousands of cells and now you need to do a mass-format.

    This assumes your data is manually entered, and the formatting will happen as you go. If I guessed wrong, please repost.

    '''''''''''''''''

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Intersect(Target, Range("A1:D10")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub
    If Target.Value = 0 Or Application.IsText(Target.Value) = True Then
    Target.HorizontalAlignment = xlCenter
    Else
    Target.HorizontalAlignment = xlRight
    End If
    End Sub

    ''''''''''''''''''''''

  3. #3
    Board Regular
    Join Date
    May 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Tom!

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
  •