Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Negative Values in Excel

Is it possible to have a series of cells automatically add the negative sign
in front of an inputed number?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Negative Values in Excel

Either by formula:

=-A1

or using paste special:
Type -1 in a cell, copy the cell, select the range, use Paste Special,
Operation Multiplication, to multiply the range by -1.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"jlojones821" wrote in message
...
Is it possible to have a series of cells automatically add the negative
sign
in front of an inputed number?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default Negative Values in Excel

This is a modification of one of Bernie Deitrick's replies earlier this week

Copy the code below, right-click the sheet tab, select "View Code" and paste
the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers to be negated (!!) will be entered.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If (Mid(Target.Value, 1, 1) = "-") Then
Target.Value = Target.Value
Else
Target.Value = Target.Value * -1
End If
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"jlojones821" wrote in message
...
Is it possible to have a series of cells automatically add the negative
sign
in front of an inputed number?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Negative Values in Excel

We can streamline that code a little bit...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or _
Intersect(Range("D:D"), Target) Is Nothing Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If Left(Target.Value, 1) < "-" Then
Target.Value = -Target.Value
End If
Reset:
Application.EnableEvents = True
End Sub

Rick


"Bernard Liengme" wrote in message
...
This is a modification of one of Bernie Deitrick's replies earlier this
week

Copy the code below, right-click the sheet tab, select "View Code" and
paste the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers to be negated (!!) will be entered.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If (Mid(Target.Value, 1, 1) = "-") Then
Target.Value = Target.Value
Else
Target.Value = Target.Value * -1
End If
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"jlojones821" wrote in message
...
Is it possible to have a series of cells automatically add the negative
sign
in front of an inputed number?




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default Negative Values in Excel

I was being lazy!
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"Rick Rothstein (MVP - VB)" wrote in
message ...
We can streamline that code a little bit...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or _
Intersect(Range("D:D"), Target) Is Nothing Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If Left(Target.Value, 1) < "-" Then
Target.Value = -Target.Value
End If
Reset:
Application.EnableEvents = True
End Sub

Rick


"Bernard Liengme" wrote in message
...
This is a modification of one of Bernie Deitrick's replies earlier this
week

Copy the code below, right-click the sheet tab, select "View Code" and
paste the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers to be negated (!!) will be entered.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If (Mid(Target.Value, 1, 1) = "-") Then
Target.Value = Target.Value
Else
Target.Value = Target.Value * -1
End If
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"jlojones821" wrote in message
...
Is it possible to have a series of cells automatically add the negative
sign
in front of an inputed number?








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Negative Values in Excel

LOL... Understood (I've been guilty of that myself plenty of times).

Rick


"Bernard Liengme" wrote in message
...
I was being lazy!
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"Rick Rothstein (MVP - VB)" wrote in
message ...
We can streamline that code a little bit...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or _
Intersect(Range("D:D"), Target) Is Nothing Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If Left(Target.Value, 1) < "-" Then
Target.Value = -Target.Value
End If
Reset:
Application.EnableEvents = True
End Sub

Rick


"Bernard Liengme" wrote in message
...
This is a modification of one of Bernie Deitrick's replies earlier this
week

Copy the code below, right-click the sheet tab, select "View Code" and
paste the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers to be negated (!!) will be entered.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
If (Mid(Target.Value, 1, 1) = "-") Then
Target.Value = Target.Value
Else
Target.Value = Target.Value * -1
End If
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"jlojones821" wrote in message
...
Is it possible to have a series of cells automatically add the negative
sign
in front of an inputed number?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change my negative values to zeros in Excel? N_Davis Excel Discussion (Misc queries) 2 September 27th 07 07:09 PM
entering negative time values in excel dona Excel Discussion (Misc queries) 5 March 13th 06 08:23 AM
how to turn positive to negative values in excel Paula1 Excel Worksheet Functions 4 February 23rd 06 10:54 PM
how do i hide negative values in excel ccarolla Excel Discussion (Misc queries) 3 December 14th 05 12:09 AM
Formula to make Negative Values Positive & Positive Values Negative? mustard Excel Discussion (Misc queries) 4 September 26th 05 10:05 PM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"