![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 72
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
|
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 |
|
Board Regular
Join Date: May 2002
Posts: 72
|
Thanks Tom!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|