ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   SET DEFAULT VALUES IN CELL TO RECORD NEGATIVE (https://www.excelbanter.com/excel-discussion-misc-queries/119953-set-default-values-cell-record-negative.html)

Prasad Gopinath

SET DEFAULT VALUES IN CELL TO RECORD NEGATIVE
 
I would like to set the deufault values of a range of cells in my spread
sheet to negative.

EXAMPLE - If I had to type in -212, when I type in the cell 212 it should
autmatically record the same as -212.

Is there a way I can set the cell values so ths can be accomplished

Prasad

Bernard Liengme

SET DEFAULT VALUES IN CELL TO RECORD NEGATIVE
 
No but you can type a range of numbers, then in an unused cell (say Z1)
enter -1
Copy Z1
Select all of the aforesaid range, use Edit |Paste Special and check the
Multiple box, click OK
Now delete Z1
done
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Prasad Gopinath" wrote in
message ...
I would like to set the deufault values of a range of cells in my spread
sheet to negative.

EXAMPLE - If I had to type in -212, when I type in the cell 212 it should
autmatically record the same as -212.

Is there a way I can set the cell values so ths can be accomplished

Prasad




Gord Dibben

SET DEFAULT VALUES IN CELL TO RECORD NEGATIVE
 
You cannot pre-format the cells as negative.

You could use event code to change them to negative as you enter.

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

Right-click on the sheet tab and "View Code"

Copy/paste the above into that module.

Edit the range of A1:A10 to suit.


Gord Dibben MS Excel MVP

On Thu, 23 Nov 2006 10:48:02 -0800, Prasad Gopinath
wrote:

I would like to set the deufault values of a range of cells in my spread
sheet to negative.

EXAMPLE - If I had to type in -212, when I type in the cell 212 it should
autmatically record the same as -212.

Is there a way I can set the cell values so ths can be accomplished

Prasad



Deepak

SET DEFAULT VALUES IN CELL TO RECORD NEGATIVE
 
Format Category Custom and use ##"-"##

"Gord Dibben" wrote:

You cannot pre-format the cells as negative.

You could use event code to change them to negative as you enter.

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

Right-click on the sheet tab and "View Code"

Copy/paste the above into that module.

Edit the range of A1:A10 to suit.


Gord Dibben MS Excel MVP

On Thu, 23 Nov 2006 10:48:02 -0800, Prasad Gopinath
wrote:

I would like to set the deufault values of a range of cells in my spread
sheet to negative.

EXAMPLE - If I had to type in -212, when I type in the cell 212 it should
autmatically record the same as -212.

Is there a way I can set the cell values so ths can be accomplished

Prasad





All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com