View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Custom number format codes for negative numbers

Mr. Phillips will see your posts.

Thanks for the feedback.


Gord

On Thu, 7 Sep 2006 13:25:01 -0700, IJ wrote:

Hello Mr. Dibben,

Thank you very much !!!! :)

I really appreciate you and Mr. Phillips taking the time to help me
out...Please thank him for me.

Thanks again !!!)

Take care and KIP

IJ :)

P.S. I want apologize in advance...it is possible that this post may come
omre than once as I did not get the post confirmed window my first time
around...
so I reposted. Thanks !! :)

"Gord Dibben" wrote:

You would change the parameters at the Const WS_RANGE as String line.

The code I posted used the range "A1:A10"

"A:A" would be column A
"A:E" would be columns A through E

"1:1" would be row 1
"1:6" would be rows 1 through 6


Gord


On Thu, 7 Sep 2006 12:45:02 -0700, IJ wrote:

Hello Mr. Dibben,

I would like to thank you and Mr. Phillips for your assistance...I really
appreciate the information and help.

I would like to ask if either you or Mr. Phillips knows if this coding can
be applied to a sepcific row or column in an Excel worksheet? Any
information either of you may be able to provide will, again, be greatly
appreciated. Thanks again !!!

Take care and KIP

Sincerely,

IJ

"Gord Dibben" wrote:

You cannot custom format a cell to become negative.

You can use event code to change the value as you enter a number.

With thanks to Bob Phillips for the basic code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10"
Dim cell As Range
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Value = .Value * -1
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

This is event code and will go into the sheet module.

Right-click on a sheet tab and "View Code".

Copy/paste the event code into that module.

As you enter numbers in A1:A10 they will become negative.


Gord Dibben MS Excel MVP


On Thu, 7 Sep 2006 11:29:02 -0700, IJ wrote:

Hello,

I am trying to find out what the custom number format code for creating only
negative numbers is?

All I want is to be able to give any cell, I choose in my worksheet, a
negative value so that I do not have to enter a negative sign or enter ( )
every time I input a number.

Any help or information any one may be able to provide will be greatly
appreciated.

Thanks for reading my inquiry.

Take care and KIP

IJ





Gord Dibben MS Excel MVP