custom number format alignment

dim4x4

Board Regular
Joined
May 8, 2002
Messages
108
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.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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

''''''''''''''''''''''
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top